none
Compiler Error Message: CS0433 - Occurs only when you Publish the website in VS2005

    Question

  • Hi all -

    Just wanted to share the information that we came across today. This is something you may want to look into if you get this error after you PUBLISH your ASP.NET application from VS2005 (and not if you run them in VS2005 or just COPY all the files to your server manually).

    Compiler Error Message CS0433 occurs when two different assemblies referenced in your application contain the same namespace and type, which produces ambiguity.

    How could this happen only when we PUBLISH the website and not when you copy the files over physically or run them in VS2005 directly? 

    Here is my reasoning!  I found that we had a class (say 'GetAddress') declared in the application and also happened to have a webpage with the same name (in this case 'GetAddress.aspx'). As you may be aware, on PUBLISH using VS2005 (.dll's that are created with names that are randomly generated and are referenced in the .ASPX page), a separate class is created for each of the .ASPX pages you have in the solution with the same name of the .ASPX page. 

    Using Reflection, you should be able to look at this.  Since we missed out on the NAMESPACE convention (are not included as default in VS2005), there appeared to be 2 GetAddress Classes after we published the solution.

    Ofcourse, maintaining separate Namespaces would have handled this in the first place. 

    Wednesday, March 21, 2007 9:14 PM

Answers

  • yes, i have a default.aspx and master page default.master and i get the error. So I remove master page and create new with other name, and the error disappear.

    Friday, January 11, 2008 3:42 PM

All replies

  • yes, i have a default.aspx and master page default.master and i get the error. So I remove master page and create new with other name, and the error disappear.

    Friday, January 11, 2008 3:42 PM
  • I've just spent hours trying to fix the same problem, and thought I'd add the solution that we found to save other poor souls tearing their hair out, and to increase my geek karma.

     

    The problem was with a project that I've inherited and which I'm assuming went through a few different conversions to vs2005 before the definitive one was settled on.  It had an app_code directory which was excluded and then an app_code_old directory which was included in the project. The files in app_code and app_code_old were identical.  The problem seemed to have arisen because although app_code\filename.cs was excluded, the project was still referencing it, so there were 2 references to filename.cs.  We changed the namespace in app_code\filename.cs (and later deleted the entire app_code directory) et voila, it worked like a dream (well, a kind of sad/desperate programmer's dream!)

     

    Wednesday, January 23, 2008 5:24 PM
  •  

    Thanks a lot. Deleting the App_Code directory did work for me.
    Friday, February 15, 2008 9:53 PM
  • I had different issue causing this problem.

    When I uploaded the compiled changes to the website, I was just OVERWRITING the files.

    There were some old files which were causing the conflict

     

    I deleted the ALL the files/folders in the website and recopied them and the error disappeared

     

    Henceforth, need to clean the existing files before publishing a new one.

     

    Smile

    Thanks ALL

     

     

    Sunday, February 24, 2008 11:56 PM
  • Occurs in 2008 Team System as well.
    Try restarting IIS.   It worked for me.
    • Proposed as answer by MontAerospace Thursday, October 29, 2009 5:24 PM
    Thursday, October 29, 2009 5:24 PM
  • If you have VS2008 and a WEB Application (not WEB Site) you can't have directory named App_Code (you must remove all files from it an move it forexam. to Root folder) and delete/exclude from project that folder (App_Code). Every file you have in App_Code will be compiled during DEBUG/Publish. - this solved my problem with CS0433.
    Wednesday, December 15, 2010 2:19 PM