该项目是一个ASP。NET MVC Web应用程序针对。NET Framework 4.6.1。
突然之间(一些NuGet包升级了),我开始在运行时得到以下错误:
CS0012:“系统”类型。对象定义在一个不存在的程序集中 引用。你必须添加一个引用到程序集的netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'。
在我的主视图索引。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下运行,它就可以工作。
链接到.csproj gist
packages.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里什么都找不到。如何搜索引用它的内容?