Ad

How To Deal With The Type 'Foo' In 'File1.cs' Conflicts With The Imported Type 'Foo' In 'File2.dll' Warning

I have the following solution structure: Project A Project B (WCF) Project C (Unit Testing)

I generate a proxy from Project B. The proxy is then included in Project A and Project C. Project C also references Project A. As a result, when compiling I get over a thousand warnings of the type:

The type 'Foo' in 'File1.cs' conflicts with the imported type 'Foo' in 'File2.dll'.

What is the best solution to this problem? I tried using #PRAGMA IGNORE, but I couldn't find the warning number in this case.

Thanks!

Ad

Answer

The best case is to use different Namespaces.

So ProjectA

namespace Project.Library

ProjectB

namespace Project.Service

ProjectC

namespace Project.Test

Then, you can use an alias in your conflict class.

For example, say Project.Library.User and Project.Service.User both exist.

You want to access your library's user class in your service, you could do:

using Library = Project.Library;

namespace Project.Service
{
     public class User
     {
          public int GetUserId()
          {
              Library.User myLibUser = new Library.User();
              return myLibUser.Id;
          }
     }
}
Ad
source: stackoverflow.com
Ad