类型“对象”是在未引用的程序集中定义的(NET Standard 2.0 / .NET Framework 4.6.1) [英] Type 'Object' is defined in an assembly that is not referenced (NET Standard 2.0/.NET Framework 4.6.1)
问题描述
我正在使用
不幸的是,迁移到.NET Framework导致了在所有.NET Framework Console项目中的以下错误中:
Error CS0012类型'Object'是在不是参考。您必须添加对程序集'netstandard,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51'的引用。
其中对象
可以是任何东西:枚举
,任务
,...
如何在不出现此类错误的情况下使用.NET Framework(4.6.1)引用.NET Standard 2.0类库?
尝试在web.config中添加对netstandard的引用,如下所示:
< system.web>
< compilation debug = true targetFramework = 4.7.1>
< assembly>
< add assembly = netstandard,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51 />
< / assembly>
< / compilation>
< /system.web>
I'm using the .NET Standard 2.0 preview, on which my Class Libraries are based.
After having trouble with a few NuGet packages, especially regarding archive extraction, I decided to migrate my .NET Core 2.0 Console projects back to the .NET Framework 4.6.1.
The .NET Framework 4.6.1 is supposed to implement the .NET Standard 2.0 specification - according to different sources. Especially the dotnet/standard GitHub Repo.
Unfortunately, the migration to the .NET Framework resulted in the following errrors throughout all of .NET Framework Console projects:
Error CS0012 The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
Where Object
can be anything: Enum
, Task
, ...
How would I reference .NET Standard 2.0 class libraries with .NET Framework (4.6.1) without getting such errors?
Try to add a reference to netstandard in web.config as below:
<system.web>
<compilation debug="true" targetFramework="4.7.1">
<assemblies>
<add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/>
</assemblies>
</compilation>
</system.web>
这篇关于类型“对象”是在未引用的程序集中定义的(NET Standard 2.0 / .NET Framework 4.6.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!