Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve the "System.Tuple defined multiple times issue"?

I work on a project target WP 7.5 and above, I add a packages using the Nuget in VS 2012 which name is Coding4fun(Controls).

After that, the IDE give me a warning,

Warning 1 The predefined type 'System.Tuple' is defined in multiple assemblies in the global alias; using definition from 'c:\Users\Gao\Documents\Visual Studio 2012\Projects\TFSGit\xicihutong\packages\Coding4Fun.Toolkit.Controls.2.0.5\lib\wp71\Coding4Fun.Toolkit.Controls.dll' C:\Users\Gao\Documents\Visual Studio 2012\Projects\TFSGit\xicihutong\xicihutong\CSC xicihutong

The app runs OK, but how to solve this warning?

like image 424
Albert Gao Avatar asked Jan 13 '23 09:01

Albert Gao


1 Answers

From Compiler Warning (level 1) CS1685

This error occurs when a predefined system type such as System.Tuple is found in two assemblies. One way this can happen is if you are referencing mscorlib from two different places, such as trying to run the.Net Framework versions 1.0 and 1.1 side-by-side.

The compiler will use the definition from only one of the assemblies.

This problem occurs probably System.Tuple is defined in two different assemblies. Probably your Coding4Fun.Toolkit.Controls.dll has too besides mscorlib.dll.

If you want to look them both you can check them;

  • Get a decompiler like ILSpy or Jetbrains dotPeek.
  • Add all 3rd party assemblies.
  • Search for System.Tuple

But how to solve this warning?

You can define your 3rd party assemblies reference some aliases. You can follow in your project

Reference -> Properties -> Aliases ->

And change "global" to something different.

Check out for information extern alias (C# Reference)

like image 183
Soner Gönül Avatar answered Jan 24 '23 10:01

Soner Gönül