[Mono-bugs] [Bug 532679] New: Precompiled website with themes causes 'virtualPath' NullException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Aug 19 22:28:59 EDT 2009


           Summary: Precompiled website with themes causes 'virtualPath'
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: x86
        OS/Version: openSUSE 11.1
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Web
        AssignedTo: mhabersack at novell.com
        ReportedBy: chrisbrown76 at hotmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0;
Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729)

Running a precompiled website with an App_Themes folder causes a NullException
for parameter 'virtualPath' when browsing to any page in the site. The site was
written in VB.NET.

Reproducible: Always

Steps to Reproduce:
1. Create new website project in VS.NET (just default.aspx page is ok).
2. Add a theme (do not need to create any theme files e.g css).
3. Precompile site using 'aspnet_compiler'.
4. Run site under XSP and browse to 'Default.aspx'.
Actual Results:  
Following error message:

Argument cannot be null. Parameter name: virtualPath

Description: HTTP 500. Error processing request.

Stack Trace:

System.ArgumentNullException: Argument cannot be null.
Parameter name: virtualPath
  at System.Web.VirtualPathUtility.IsAbsolute (System.String virtualPath)
  at System.Web.VirtualPathUtility.IsRooted (System.String virtualPath)
  at System.Web.Compilation.BuildManager.GetAbsoluteVirtualPath (System.String
virtualPath) [0x00000]
  at System.Web.Compilation.BuildManager.FixVirtualPaths () [0x00000]
  at System.Web.Compilation.BuildManager.LoadPrecompilationInfo () [0x00000]
  at System.Web.Compilation.BuildManager..cctor () [0x00000]

Version information: Mono Version: 2.0.50727.1433; ASP.NET Version:

Expected Results:  
Default.aspx page displays normally.

This bug appears to be occurring because the .compiled file that is created for
the Theme (e.g Theme_Theme1.compiled) has a 'virtualPath' attribute in the
'preserve' node of '/App_Themes/Theme1/'. It also has a 'resultType' of '3'.
This means that in the System.Web.Compilation.BuildManager.LoadPrecompiled
method (called by System.Web.Compilation.BuildManager.LoadPrecompilationInfo)
this compiled file is passed to
System.Web.Compilation.BuildManager.LoadPageData which extracts the virtualPath
and this is in turn later processed by
System.Web.Compilation.BuildManager.FixVirtualPaths. The trailing '/' means
this method ultimately passes an empty string to
System.Web.VirtualPathUtility.IsAbsolute which results in the null exception

I resolved this on my system by adding the following method to

public static bool IsThemeDirectory (string virtualPath)
            string checkPath = ToAppRelative(virtualPath);
            return (checkPath.StartsWith("~/App_Themes/",
StringComparison.InvariantCultureIgnoreCase) ||

I also then modified System.Web.Compilation.BuildManager.LoadPageData as
follows to call this method:

static void LoadPageData (XmlTextReader reader)
            PreCompilationData pc_data = new PreCompilationData ();

            while (reader.MoveToNextAttribute ()) {
                string name = reader.Name;
                if (name == "virtualPath")
                    if (!VirtualPathUtility.IsThemeDirectory(reader.Value))
                        pc_data.VirtualPath = reader.Value;
                else if (name == "assembly")
                    pc_data.AssemblyFileName = reader.Value;
                else if (name == "type")
                    pc_data.TypeName = reader.Value;
            if (precompiled == null)
                precompiled = new Dictionary<string, PreCompilationData>
            precompiled.Add (pc_data.VirtualPath, pc_data);

This resolved the issue when using XSP2 or mod_mono.

Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list