Ensking
Ensking

Reputation: 31

Visual Studio Error CS0433: The type exists in both... (Unity-Accord.net)

I'm receiving this error messange:

The type NormalDistribution exists in both Accord.Statistics, Version=3.8.2.0, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7 and Accord.Statistics, Version=3.8.2.0, Culture=neutral, PublicKeyToken=null

How can I solve this?

Upvotes: 3

Views: 24792

Answers (2)

Mac
Mac

Reputation: 53

So I had this problem today. Seems I had two versions of the DLL I fixed this by removing both from project

Solution > References -- check for the files with similar names and remove them. then re-add the correct version.

Clash solved.

Upvotes: 4

Ross Gurbutt
Ross Gurbutt

Reputation: 1029

It's possible this is related to: Where does error CS0433 “Type 'X' already exists in both A.dll and B.dll ” come from?

In summary:
This can sometimes happen when Visual Studio fails to correctly clear out cached state as part of rebuilding. I have noticed it occurring more frequently with recent updates of VS2019.

Try the following steps and see if it helps:

  1. Delete all bin/obj directories for your solution using File Explorer
  2. Close VisualStudio and restart PC (this seems odd and unnecessary, but have found it can help)
  3. Reopen VisualStudio and do a full rebuild

It is also possible, although much more unlikely, that you genuinely have two references to the same package / dll with different hint paths. One retrieving a signed version, and one not (although if this is an external package it seems unlikely you'd have an unsigned version available). If the above steps don't work, check your project file for duplicate references.

Upvotes: 2

Related Questions