locked
CS0436 problems with WDP 2008 RRS feed

  • Question

  • User-175573020 posted

    Hi,

    Am having an issue with building my web deployment project - it doesn't actually affect the end result, but I'd like to know how to solve the reported warning. AFAIK, CS0436 means that a class is declared twice within the solution, but in this case, it's only declared once but copied into a temp folder and it's the copy that's the cause of the problem. I'm at a loss because I can't control how the WDP works and therefore avoid the clash. Here's the top of the output - I get about fifteen CS0436 errors, all in the same format.

    Any suggestions would be greatfully accepted.

     Dan

    ------ Build started: Project: EBS.Web.csproj_deploy, Configuration: Release Any CPU ------
    if exist ".\TempBuildDir\" rd /s /q ".\TempBuildDir\"
    C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v /EBS.Web.csproj -p D:\CodeSvn\EBS.Web.csproj_deploy\Source -f .\TempBuildDir\

    d:\CodeSvn\EBS.Web.csproj_deploy\Source\App_Code\SiteMasterPage.cs(10): warning CS0436:
    The type 'EBS.Web.MasterMessageItem' in 'c:\Users\dan.CWEB\AppData\Local\Temp\Temporary ASP.NET Files\ebs.web.csproj\9d0f2c80\74651221\App_Code.3.cs' conflicts  with the imported type 'EBS.Web.MasterMessageItem' in 'c:\Users\dan.CWEB\AppData\Local\Temp\Temporary ASP.NET Files\ebs.web.csproj\9d0f2c80\74651221\assembly\dl3\4aa7284d\b2571d87_e7bbc801\EBS.Web.DLL'. Using the type defined in 'c:\Users\dan.CWEB\AppData\Local\Temp\Temporary ASP.NET Files\ebs.web.csproj\9d0f2c80\74651221\App_Code.3.cs'.

    Thursday, May 22, 2008 5:11 AM

Answers

  • User-762694769 posted

    Where *exactly* is MasterMessageItem defined?

    Looking at the error, it seems to exist in App_Code\SiteMasterPage.cs. If that is indeed the only place it should be, then code in the App_Code should get built into an assembly named similarly to App_Code.dll, and you should *NOT* be seeing it in bin\EBS.Web.DLL. If EBS.Web.Dll was compiled from a *separate* referenced project, then SiteMasterPage.cs should not be redefining it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 22, 2008 6:28 PM

All replies

  • User-762694769 posted

    It looks like one of your assemblies in BIN 'EBS.Web.DLL' already contains the type 'EBS.Web.MasterMessageItem'. In the error message, it seems that App_Code\siteMasterPage.cs also declares the exact same type, so you might want to check this file for a start.

    Thursday, May 22, 2008 2:03 PM
  • User-175573020 posted

    The class is only defined once in the solution. MasterMessageItem gets built into EBS.web.dll as part of the website itself and then WDP tries to build it again for some reason.

    Thursday, May 22, 2008 4:13 PM
  • User-762694769 posted

    Where *exactly* is MasterMessageItem defined?

    Looking at the error, it seems to exist in App_Code\SiteMasterPage.cs. If that is indeed the only place it should be, then code in the App_Code should get built into an assembly named similarly to App_Code.dll, and you should *NOT* be seeing it in bin\EBS.Web.DLL. If EBS.Web.Dll was compiled from a *separate* referenced project, then SiteMasterPage.cs should not be redefining it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 22, 2008 6:28 PM
  • User-175573020 posted

    Ah-ha, I have found the solution. The whole site is a Web Application Project rather than a Web Site project. It also has an App_Code folder. It appears that what is happening is that the WAP is acting like a website and compiling App_Code into its own DLL as well as into a DLL for all the code in the WAP, hence the two conflicting versions of the class.

    The solution is to rename my App_Code folder to something else and then the errors disappear. The question remains however why the build server is making a special case of App_Code and compiling it by itself as well as within the main DLL

    Friday, June 6, 2008 11:11 AM
  • User-762694769 posted

    Thanks for following up on this! Glad to know that you have found the solution.

    When you use WDP on a web application, there could be up to 3 stages in the build process:

    1. Building all .cs files into an assembly in bin.

    2. Using aspnet_compiler.exe to compile aspx pages.

    3. Merging output assemblies.

    After step 1, the web application actually looks like a web site - it has only .aspx pages and all the code-files have been compiled into a bin assembly. However, it is not clear why the source files in App_Code are still copied over though.

    In step 2, aspnet_compiler.exe is just treating the output from step 1 as a regular web site. Thus if all the sources in App_Code were copied over, then it will be compiled a second time into another dll.

     

    Friday, June 6, 2008 2:45 PM
  • User-175573020 posted

    I'm guessing it is the Web Deploymnet Project that we are using in our Release build.

    Friday, June 6, 2008 5:48 PM
  • User-956737627 posted

    Hi, 

    In my web application I had a page called Projects.aspx & also had a class called Projects in my App_Code folder.
    I could use the Projects Class when I was working in the pages inside ~/ControlPanel folder but when I tried
    to use it in my root folder- where Projects.aspx existed - I faced this warning:

    Warning 1 The type 'Projects' in 'c:\Users\arash.meimandi\AppData\Local\Temp\Temporary ASP.NET Files\soroushsaberi\065de1b2\8277756d\App_Web_uqsoyayy.5.cs' conflicts with the imported type 'Projects' in
    'c:\Users\arash.meimandi\AppData\Local\Temp\Temporary ASP.NET Files\soroushsaberi\065de1b2\8277756d\App_Code.qbfpjwpy.dll'. Using the one in 'c:\Users\arash.meimandi\AppData\Local\Temp\Temporary ASP.NET Files\soroushsaberi\065de1b2\8277756d\App_Web_uqsoyayy.5.cs'.
    c:\Users\arash.meimandi\AppData\Local\Temp\Temporary ASP.NET Files\soroushsaberi\065de1b2\8277756d\App_Web_uqsoyayy.4.cs 122 

    and I couldn't use my class methods so I deleted Projects.aspx and created a new page with a different name and the problem solved.
    Hope this experience would be usefull for any one who encounters this probelem.

    Best wishes for you all

    Thursday, September 11, 2008 4:29 AM
  • User1713683418 posted

    Thanks, HMobius!  That was exactly my problem.

    Thursday, October 16, 2008 3:33 AM