ASP.NET CodeFile versus CodeBehind

1 up for the guys at Microsoft. They thought of every eventuality it seems.

I was stumped for a while on a weird error:


2011-04-18 10:52:34,416 [11] ERROR 4/18/2011 10:52:34 AM Error occurred: System.Web.HttpException (0×80004005): The file Page.aspx.vb does not exist.
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ProcessCodeFile(VirtualPath codeFileVirtualPath)
at System.Web.UI.TemplateParser.ProcessMainDirectiveAttribute(String deviceName, String name, String value, IDictionary parseData)
2011-04-18 10:52:34,416 [11] ERROR 4/18/2011 10:52:34 AM Stack Trace: at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.UI.TemplateParser.ProcessCodeFile(VirtualPath codeFileVirtualPath)
at System.Web.UI.TemplateParser.ProcessMainDirectiveAttribute(String deviceName, String name, String value, IDictionary parseData)


What was odd was that I was using a compiled, updateable application. Why on earth was it trying to reference the code behind when everything is dumped into a .dll file?

Turns out we have the CodeBehind and CodeFile attributes of the @Page directive… Nice one Microsoft! So even though the rest of the application runs from the dll I can change one page to still run from an un-compiled .vb file by changing CodeBehind to CodeFile!!

Hope this helps someone else who inherits a project with that directive changed on only one page.

Cheers!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 272 other followers