Random "virtualPath" error - Asp.Net application
Full error: "The value cannot be empty. Parameter name: virtualPath". This happens in our QA and learning environments (Win 2003 Server and IIS6), but of course, it challenges rest in the debugger. Even worse, despite a sensible global error handler, no stack trace follows the error, and nothing is written to the event log. The application is a large fully globalized Asp.Net (VB) web application running on version 2.0 of the Framework. It uses the usual "App_LocalResources" structure for resx files, and it is done quite well today. There are several places in the application where code like this is used:
Dim x As New Compilation.ExpressionBuilderContext(Control.TemplateControl)
Dim path As String = x.VirtualPath
Dim res As String = HttpContext.GetLocalResourceObject(path, resourceKey).ToString
However, the Try / Catch block around this code works correctly when I forcefully change the path variable. We also use this syntax everywhere for the column headings of the data grid:
<asp:TemplateColumn HeaderText="<%$ Resources:resHeader %>" >
We also use a significant amount of Ajax and dynamically load ascx controls into placeholders all the time. If anyone can figure this out, I would really appreciate some help.
Thanks Larry
source to share
It may sound silly, but heck, I've had this happen to me before.
if you copy and paste your error I noticed that it says "virtualPath" (lowercase v); in your example code, the property you are using has VirtualPath (uppercase V).
Also, what is the actual exception you are getting? a NullReferenceException?
source to share