views:

1043

answers:

3

The full error is - "Value cannot be null. Parameter name: virtualPath". This is occurring in our QA and Training environments (Win 2003 Server & IIS6) but of course defies recreation in a debugger. To make matters worse, despite a reasonable global error handler, no stack trace accompanies the error and nothing is written to the event log. The app is a large fully globalized Asp.Net (VB) web application running under the 2.0 Framework. It uses the usual "App_LocalResources" structure for resx files and to date has performed quite well. There are several places in the app 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 properly when I force the "path" variable to be nothing. We also use this syntax everywhere for data grid column headers:

<asp:TemplateColumn HeaderText="<%$ Resources:resHeader %>" >

We also use a considerable amount of Ajax and dynamically load ascx controls into placeholders constantly. If anyone has any insight into this I'd greatly appreciate the help.

Thanks, Larry

A: 

this might sound silly, but heck i have had this happen to me before.

if you copy and pasted your error, i notice it says "virtualPath" (lower case v); whil in your sample code, the property you use has VirtualPath (upper case V).

Also, what is the actual exception you are getting? a NullReferenceException?

Victor
A: 

Thanks for the response and good catch on the case difference. The two "virtualPath" items mentioned are a bit different. The uppercase "VirtualPath" is a property of the ExpressionBuilderContext object. The lowercase "virtualPath" is the parameter name passed to the GetLocalResourceObject function. I believe the "<%$ Resources:resourceKey %>" syntax is just sugar coating the GetLocalResourceOjbect call. Our current assumption is that in some cases an attempt is made to resolve a resource and for some unknown reason the path to the control and it's associated resx file can't be determined. The actual error message is just "Value cannot be null. Parameter name: virtualPath".

Thanks.

Larry P
+1  A: 

Follow up - make sure your servers are up to the proper patch level.
The root cause of this turned out to be 3 QA VMs that did not have
2.0 .Net Framework SP1 installed.

Larry P