gpt4 book ai didi

asp.net - 您必须添加对程序集“netstandard,Version=2.0.0.0”的引用

转载 作者:行者123 更新时间:2023-12-03 05:14:20 26 4
gpt4 key购买 nike

该项目是一个面向 .NET Framework 4.6.1 的 ASP.NET MVC Web 应用程序。

突然之间(一些 NuGet 包已升级)我开始在运行时收到以下错误:

CS0012: The type 'System.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'.

在我的主视图 Index.cshtml 中,在我使用 @Html.ActionLink 的行中

我的计算机中确实安装了 .NET Core SDK 2.0 和 .NET Framework 4.7.1,但我不想包含对它的引用。这只是一个 .NET Framework Web 应用程序,它托管在 Windows IIS 上,安装的框架是 4.6.1,服务器中没有安装 NET Core。

那么为什么要求添加对 netstandard 的引用呢?如何在不引用 netstandard 而是完整的 Windows .NET Framework 4.6.1 的情况下修复它?

我已经检查了之前的提交,效果很好,但我仍然收到此错误。所以它与升级的 NuGet 包无关。似乎是我本地开发机器上的东西。

如果将应用程序发布到目录并使用 IIS 运行它,它就可以工作。

Link to .csproj gist

包.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net46" />
<package id="BundleTransformer.Core" version="1.9.69" targetFramework="net46" />
<package id="BundleTransformer.Handlebars" version="1.9.73" targetFramework="net46" />
<package id="BundleTransformer.Less" version="1.9.69" targetFramework="net46" />
<package id="BundleTransformer.Yui" version="1.9.52" targetFramework="net46" />
<package id="Dapper" version="1.42" targetFramework="net46" />
<package id="EcmaScript.Net" version="1.0.1.0" targetFramework="net46" />
<package id="EntityFramework" version="6.0.0" targetFramework="net46" />
<package id="Glimpse" version="1.8.6" targetFramework="net46" />
<package id="Glimpse.AspNet" version="1.9.2" targetFramework="net46" />
<package id="Glimpse.Mvc5" version="1.5.3" targetFramework="net46" />
<package id="JavaScriptEngineSwitcher.Core" version="1.2.4" targetFramework="net46" />
<package id="JavaScriptEngineSwitcher.V8" version="1.3.0" targetFramework="net46" />
<package id="jQuery" version="2.1.3" targetFramework="net46" />
<package id="jQuery.Validation" version="1.13.1" targetFramework="net46" />
<package id="LowercaseDashedRoute" version="1.0.14" targetFramework="net46" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net46" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net46" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net46" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net46" />
<package id="Microsoft.SqlServer.Compact" version="4.0.8876.1" targetFramework="net46" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" />
<package id="Moment.js" version="2.10.2" targetFramework="net46" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net46" />
<package id="NWebsec" version="5.1.1" targetFramework="net46" />
<package id="NWebsec.Core" version="2.1.0" targetFramework="net46" />
<package id="NWebsec.Mvc" version="5.1.1" targetFramework="net46" />
<package id="Owin" version="1.0" targetFramework="net46" />
<package id="Respond" version="1.4.2" targetFramework="net46" />
<package id="Sendgrid" version="6.3.0" targetFramework="net46" />
<package id="SendGrid.SmtpApi" version="1.3.1" targetFramework="net46" />
<package id="Serilog" version="2.6.0" targetFramework="net46" />
<package id="Serilog.Enrichers.Environment" version="2.1.2" targetFramework="net46" />
<package id="Serilog.Sinks.File" version="3.2.0" targetFramework="net46" />
<package id="Serilog.Sinks.RollingFile" version="3.3.0" targetFramework="net46" />
<package id="Serilog.Sinks.Sentry" version="2.1.4" targetFramework="net46" />
<package id="SerilogWeb.Classic" version="2.1.17" targetFramework="net46" />
<package id="SharpRaven" version="2.2.0" targetFramework="net46" />
<package id="System.Data.SQLite" version="1.0.108.0" targetFramework="net46" />
<package id="System.Data.SQLite.Core" version="1.0.108.0" targetFramework="net46" />
<package id="System.Data.SQLite.EF6" version="1.0.108.0" targetFramework="net46" />
<package id="System.Data.SQLite.Linq" version="1.0.108.0" targetFramework="net46" />
<package id="Twitter.Bootstrap.Less" version="3.3.4" targetFramework="net46" />
<package id="WebActivatorEx" version="2.0.6" targetFramework="net46" />
<package id="WebGrease" version="1.6.0" targetFramework="net46" />
<package id="YUICompressor.NET" version="2.7.0.0" targetFramework="net46" />
</packages>

使用 VS2017 将应用程序发布到文件系统时,我在输出中收到以下警告:

The following assembly has dependencies on a version of the .NET Framework that is higher than the target and might not load correctly during runtime causing a failure: netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51. The dependencies are: System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089. You should either ensure that the dependent assembly is correct for the target framework, or ensure that the target framework you are addressing is that of the dependent assembly.

但我在 System.Transactions 上找不到任何内容。我如何搜索引用它的内容?

最佳答案

我认为解决方案可能是 this issue on GitHub :

Try add netstandard reference in web.config like this:"

<system.web>
<compilation debug="true" targetFramework="4.7.1" >
<assemblies>
<add assembly="netstandard, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.7.1" />

我知道您使用的是 4.6.1,但选择 .NET 4.7.1 很重要,因为较旧的 Framework 版本与 .NET Standard 2.0 不完全兼容。

我从痛苦的经历中知道了这一点,当我引入 .NET Standard 库时,我遇到了很多 NUGET 包和引用中断的问题。您需要考虑的另一个更改是升级到 PackageReferences 而不是 package.config 文件。

参见this guide你可能还想要 tool to help the upgrade 。但它确实需要最新的 VS 15.7 版本。

关于asp.net - 您必须添加对程序集“netstandard,Version=2.0.0.0”的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49925484/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com