Question

I have an error, when I try to build my .net 4, c# project. Everything works great, but when I add an external reference to a given DLL, it stops working, it can't build, throws this type of some errors:

Error 36 The type 'System.Tuple' exists in both 'C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\mscorlib.dll' and 'C:\Projects\Project1\ExternalRefernces\SharpSNMP\SharpSnmpLib.dll' C:\Projects\Project1\CheckerStore.cs 17 21

Note, I did not do anything with the new library, just added as a reference. Any ideas?

Was it helpful?

Solution

What you can do is either change the target version to 3.5 or make some changes in the SharpSNMPLib. The source can be fetched from here or here.

The changes you need to make is specifically moving the System.Tuple type somewhere else.

Edit:
I belive you have added a reference to a precomplied DLL. A DLL that is NOT compiled for framework version 4. What you need to do is download the source code (see links above) and compile the project with target version 4.

Why you need to do this is because there are conditional build parameters depending on the framework target version. The SharpSNMPLib System.Tuple is used for version <= 3.5 and the framework System.Tuple is used for version >= 4.

Edit:

  • Reproduced your problem using framework System.Tuple and SharpSNMPLib.dll.

  • Successfully built SharpSNMPLib targeted on version 4.

  • Successfully built application using framework System.Tuple and the new SharpSNMPLib.dll.

OTHER TIPS

You can solve this problem by specifying an external alias. Select the SharpSNMP reference in your project. In the properties window change Aliases from global to say SharpSNMP. In your code type this

extern alias SharpSNMP;

...

System.Tuple<T1,T2> sysTulpe;
SharpSNMP::System.Tuple<T1,T2> sharpTulpe;

or

extern alias SharpSNMP;

using SharpSystem = SharpSNMP::System;

...

System.Tuple<T1,T2> sysTulpe;
SharpSystem.Tuple<T1,T2> sharpTulpe;

See Aliases: overcoming name conflicts part 2: extern alias

Simply go to your CheckerStore.cs file, line 1721 (if I'm right). Find the Tuple class, and reference it using it's fully qualified name.

The library for some reason re-implements some system types. Likely reason is to make code to be source level compatible when using older versions of the framework.

Most likely there is a version of this SharpSNMP library that works with 4.0 framework. Check if you already have correct on in your source tree. Check with creators of the library what versions of the assembly you need to use with given framework version and what is recommended way of doing it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top