Last post Oct 16, 2008 07:33 AM by ghotiman
May 22, 2008 09:11 AM|HMobius|LINK
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.
------ 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'.
Web Deployment Project
May 22, 2008 06:03 PM|hongping|LINK
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
May 22, 2008 08:13 PM|HMobius|LINK
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.
May 22, 2008 10:28 PM|hongping|LINK
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.
Jun 06, 2008 03:11 PM|HMobius|LINK
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
Jun 06, 2008 06:45 PM|hongping|LINK
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.
Jun 06, 2008 09:48 PM|HMobius|LINK
I'm guessing it is the Web Deploymnet Project that we are using in our Release build.
Sep 11, 2008 08:29 AM|arash_meimandi|LINK
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
ASP.NET web development
Oct 16, 2008 07:33 AM|ghotiman|LINK
Thanks, HMobius! That was exactly my problem.