VS/C#/VB “The type exists in both versions” Error

Some .NET libraries or components may use the same type / enum name which can make the Visual Studio compiler generate an error with the message:

“the type exists in both versions”

Visual Studio compiler error

In order to fix that issue, you can do as follow:

  1. Goto References and select one of the libraries that generated this error.
  2. In the Properties change the Alias property to ‘MyAlias’.
  3. Add to the top of the class that used the library:
//Declear the alias name of the library
extern alias MyAlias;

//------------------------------
//The rest of your code...
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

That’s it 🙂

From now on you can create a reference to the library like:

MyAlias.TheLibrary.ClassName xyz;