Skip to content

PreCompile Issue - CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

I am sure many developers have run into the classic "It works on my machine" problem. This one was a little weird. I have been working on a new solution with ASP.NET 2.0. Running locally using the In built Cassini Web Server all is fine. Once I moved the solution over to IIS I got the following Message with the Yellow Screen of Death.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

Source Error:

Line 120:        public login_aspx() {
Line 121:            string[] dependencies;
Line 122:            ((Login)(this)).AppRelativeVirtualPath = "~/login.aspx";
Line 123:            if ((global::ASP.login_aspx.@__initialized == false)) {
Line 124:                global::ASP.login_aspx.@__stringResource = this.ReadStringResource();

The Solution:

Change the Name of the Codebehind Class Associated with the Login.aspx, by default Vs2005 will name the code-behind class the same name as your .aspx or ascx file. Obviously this clashes with the inbuilt login control.

What make this unusal is that cassini seems to be able to deal with the error. I have not investigated to see if it ignores the exception, but from searches on the web. The PreCompile option when building the project seems to be part of the problem. So I changed the name of my page and all is good

 

Posted in Development