Unity 5 Error: The imported type is defined multiple times

Hi

After upgrading my Project, which is based on the Unity Bootcamp Photon Demo, I have got these two errors:

The imported type ExitGames.Client.Photon.IPhotonPeerListener' is defined multiple times The imported type ExitGames.Client.Photon.PhotonPeer’ is defined multiple times

I have reimported the script from the assets store, but the errors are still the same.

Anybody an idea?

Okay, same problem just occurred for us today. Not sure it’s the same thing, but this is what the case was for us:

Having upgraded from unity four to five, I wanted to bring in a new version of Photon as well. I deleted the “Photon Unity Networking” folder, imported the new version and was then told that I had multiple definitions of IPhotonPeerListener and PhotonPeer just as OP had.

After some investigation, it turned out that it had to do with the Photon3Unity3d.dll file in the Assets/Plugins folder, which I had neglected to delete. In stead of overwriting it (which I’d expect) Unity had somehow kept both files, renaming the new one (by adding a one at the end):

Directory of E:\UnityProjects\NS15_u5_2\Assets\Plugins
17/09/2015  15:02           140,288 Photon3Unity3D 1.dll
05/05/2015  09:40           146,432 Photon3Unity3D.dll

Unsurprising this left us with same namespace/class declared more than once. Solution was getting rid of both files and importing the .dll again.

I just had a similar problem with importing Newtonsoft.Json.JsonReader type in Unity 2017. It turned out that I imported an asset that pulled the second Newtonsoft.Json.dll and caused the error, because I already had it in my project. I had to look into detailed logs to see the paths where the type was defined. It would be easier if they were just exposed in the console.

I had the same issue.

I suggest:

  1. Deleting all plugins and folders related to plugins and then redownloading them all.
  2. Export your project as a unity package, then import that package into a completely new project, but only import the stuff you absolutely need. You want to avoid all plugins and store-bought addons. Once it is imported you should reinstall any plugins or addons that you had. Should work fine now.

Again, only import the bare necessities (like your models, custom scripts, etc), then redownload or reinstall any additional unity packages or plugins.

This worked for me, I hope it helps you.