Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what to do if two libraries has exactly the same classes?

Tags:

c#

I have such error

Error 8 The type 'System.Threading.Volatile' exists in both 'c:\Oleg\projects\MBClient\packages\Disruptor.1.1.0\lib\net40\Atomic.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\mscorlib.dll' C:\Oleg\projects\MBClient\MBClient\CustomIndeces\CompositeIndex.cs 77 40 MBClient

I do not know what to do as fully-qualified name doesn't identify exactly which class to use. How to solve this problem?

like image 598
Oleg Vazhnev Avatar asked Nov 11 '12 17:11

Oleg Vazhnev


1 Answers

You can assign an alias to the library in VS by right-clicking the assembly in your list of references, going to properties, and setting the "alias" property to whatever you want it to be. Then to use types from this assembly, you use extern alias at the the beginning of your namespace.

Example:

namespace TestApp
{
    extern alias Threading1;
    using Threading1.System.Threading.Volatile;
}

extern alias msdn

like image 105
gotopie Avatar answered Oct 05 '22 16:10

gotopie