The type 'System.Windows.Input.ICommand' exists in both 'PresentationCore.dll' and 'System.dll'

后端 未结 4 640
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-20 07:32

I\'ve got this error that I just can\'t figure out.

I\'m using VS 2012 (VS11) on Windows 8 with .net4.5 and I get this error when compiling a project that worked wit

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-20 08:02

    c:\Windows\Microsoft.NET\Framework\v4.0.30319\System.dll

    The message is accurate, ICommand indeed exists in both assemblies for .NET 4.5. The problem is your reference to System.dll, your project is using the wrong one. The assemblies in the Microsoft.NET directory are no longer suitable to act as reference assemblies, like they were in versions of .NET prior to .NET 4.0. They should no longer be there but unfortunately are required to get C++/CLI projects built.

    Your reference to PresentationCore.dll is correct, it uses the c:\program files\reference assembly subdirectory. The proper home for reference assemblies in .NET 4.0 and up. These assemblies are special, they contain only metadata and are not a copy of the runtime assemblies.

    You'll need to fix your project. System.dll is probably not the only assembly that has this problem. Open the References node of your project and verify them one by one. Remove bad ones that point to Microsoft.NET and replace them with good ones by using Project + Add Reference. Best to just replace them all to be sure.

提交回复
热议问题