类型“对象”是在未引用的程序集中定义的(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)

查看:583
本文介绍了类型“对象”是在未引用的程序集中定义的(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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆