The type <type> exists in both DLLs

I have 1 DLL in the .Net 3.5 framework and another in 2.0. The ListBoxItem class exists in 2.0, and I linked the class in DLL 3.5 in the same namespace.

When I try to compile, I get an "exists in both" error. How can I compile this and maintain the same structure.

I do not want to reference the 2.0 DLL to 3.5 to fix this problem, I want these libraries to be separated.

+26
source share
4 answers

It doesn't seem like a good idea, no matter what, but change the namespaces and fully qualify your customs.

Otherwise, why don't you just reference the same DLL?

+6
source

It is also a suitable solution where you can determine which type to use for your purposes:

fooobar.com/questions/159380 / ...

You cannot use fully qualified names when working with extension methods, etc.

+6
source

Divide them into two different solutions: one for .NET 2.0 and the other for .NET 3.5. Otherwise, how does .NET know how to load which?

+2
source

Old thread, but wanted to add to another instance where this problem occurred. There was delaing with a project that was converted from a website to a web application in Visual Studio 2010. I started getting the type "class" exists in both ... / temporary ASP.NET / ... yada ... yada .. chatter.

In my case, the old page used a datagrid to display a list of dates, but the dataset was a list of Classes List<MyClass> , and the code in .aspx (not the code at the back) used the method of casting the data element to display ...

 <%# ((MyClass)Container.DataItem).MyDate %> 

For some reason, MyClass is throwing a type error. After doing a full search throughout the project for any possible references to double classes, etc. I did not find anything, so basically decided to see if I got rid of the cast and just went with the standard method of getting the value from the DataItem as follows:

 <%# DataBinder.Eval(Container.DataItem, "MyDate").ToString()%> 

And voila ... there is no longer a type there is an error. Not too sure why this will cause the above error to occur (and if anyone has any understanding, it will be appreciated), but the problem disappeared ...

Hope this helps someone ...

Dave

+2
source

All Articles