How to solve Error 189 The type 'XXX' exis

2019-07-20 21:32发布

问题:

I am fighting for weeks already with this creepy compilation error messages, that sometimes just go away after I run re-compile a dozen times.

I have an ASP.NET 2.0 Website (not WebApplication). When I compile I get this all the time (for different types, unpredictably).

I wonder - what does it has to do with Framework\v4.0.30319 ?? It's a .NET 2.0 project.

Error 189 The type 'XXX' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\MyWebSite\7f070f1a\b1e2bb52\App_Web_search.ascx.cc671b29.j7lvxos_.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\MyWebSite\7f070f1a\b1e2bb52\App_Web_mey4xl1t.dll'

I tried deleting these Temporary ASP.NET Files - doesn't help.

Tried to add batch="false" to compile element in web.config, takes forever to build, but the problem remains.

回答1:

You have duplicate declaration of a class or other object.

Look at the name of the class mentioned, and search both dlls for it's declaration. One of them is obviously wrong.