Deployment project dll causes "type x exists in both" errors

I have a WebApplication project, a business logic project, and a WebDeployment project for a web application.

When I create the solution, the “Release” deployment bit contains 1 dll for each of the projects, so I get one for MyWeb.dll, MyWebBusiness.dll and MyWebDeploy.dll.

When I try to start the site, it sees the same type in both MyWeb.dll and MyWebDeploy.dll and chokes.

Error message: CS0433: Type "AV" exists as in "c: \ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ Temporary ASP.NET Files \ root \ 53d45622 \ 6c032bd2 \ assembly \ dl3 \ 33f3c6b2 \ abc9430a_285ac901 \ MyWeb .DLL 'and' c: \ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727 \ Temporary ASP.NET files \ root \ 53d45622 \ 6c032bd2 \ assembly \ dl3 \ 631e5302 \ 0231160d_285ac901 \ MyWebDeploy.DLL '

+4
source share
4 answers

Some reasons I can think of:

  • Your project has an App_Code directory
  • You have a CodeFile page directive in the layout of some page instead of CodeBehind
+10
source

There is an excellent post on the forum at: http://forums.asp.net/t/980517.aspx

It seems that all that is required is the right bit of code in the web application project, and VS says: “Oh, this is the website project, so I'd rather autocompile it,” and then it crashes when it discovers that it was already compiled as one DLL.

The reasons listed by Darin above are the primary culprits.

Please note that you can get a similar error by accidentally getting two links to the same assembly, double links in the web.config assembly section, or accidentally dropping a duplicate copy of the code file into a folder in the project, but they will usually be pretty obvious if you included debugging in your web.config, and the error message should mention the assembly different from the assembly of the web application {WebAppName} .dll and the assembly with automatic compilation App_Web_ {number} .dll

There are many people who say (in the mentioned topic) that event handlers cause problems, but I think that this is just something strange in the code, which is interpreted as requiring autocompilation. I am in the same boat, I cut and put a whole bunch of example code into my web application and checked all of the above. However, on many pages there is code by which they already have the “Web Form Designer” code, so when I right-click the application on the solution explorer and select "convert to web application", nothing happens. The old code remains there, and dual compilation continues.

Therefore, I would say in addition to these posts: If the code was cut and pasted, and something that the converter does not like, it will not convert it, and double compilation will continue. The only solution is to add offensive pages as new elements, copy the markup and code (as needed), and then delete the old versions.

In my case, I just went to the website for the project, because I could not worry, and it was just a demo project.

0
source

I converted my project from a website to a web application and had a CodeFile on all pages instead of CodeBehind, although I used VS "convert to WebApp". Manually replacing the Codefile with CodeBehind solved my problem. Added so that it can help anyone else convert to webapp.

0
source

Add batch = "false" to the web.config file

Give your files fix names mainly for master pages

<compilation ... batch="false"/> ... 
0
source

All Articles