I ran into this error today and its the first time that I’ve seen it. It’s been around for a few years – since the release of Visual Studio 2005, so it’s probably old news to most people.
This “software feature” only affects users of Visual Studio 2005 Professional (and greater) who use the “Publish Web Site” feature. The “Publish Web Site” feature is not available to Visual Studio Express users.
The error occurs when you have an ASP.NET page located in your root directory (I’ll explain later why you may not see this error in subdirectories) that is named the same as an existing class in the System.Web.UI.WebControls namespace.
For example, my page was named “View.aspx” (class name “View”). Here’s the error message that I found on the published web site. The page runs fine in development and only occurs after you have used the “Publish Web Site” feature.
The reason why you may not see this in subdirectories is because Visual Studio appends the name of the directory to the class’s name. So if the class named “View” was in the subdirectory of “Work”, then Visual Studio automatically names it “Work_View” and there is no naming conflict with the System.Web.UI.WebControls.View class.
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.view_aspx’ to ‘System.Web.UI.WebControls.View’
Source Error:
Line 120: public view_aspx() {
Line 121: string[] dependencies;
Line 122: ((View)(this)).AppRelativeVirtualPath = "~/View.aspx";
Line 123: if ((global::ASP.view_aspx.@__initialized == false)) {
Line 124: global::ASP.view_aspx.@__stringResource = this.ReadStringResource();
The Work Around
You will need rename the class associated with the ASP.NET Page to something other than the name you are using.
- Open the Page’s Designer and Code pages.
- Rename the Page’s class name to something else.
- In the code behind page, just append “Page” to the class name such as “public partial class ViewPage : System.Web.UI.Page”
- In the design view page, append the same value such as “<%@ Page … CodeFile=”View.aspx.cs” Inherits=”ViewPage“… %>”
- Save and Publish your web site.
Here’s a quick list of a few class names to avoid:
|
|
You can find the complete list of class names for the System.Web.UI.WebControls namespace at: http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.aspx.
References:
Was this what was giving you so much trouble?
Nope, a quick search and I figured this out in a matter of moments.
thanks for pointing out the issue