어셈블리 'netstandard, Version = 2.0.0.0'에 대한 참조를 추가해야합니다.
이 프로젝트는 .NET Framework 4.6.1을 대상으로하는 ASP.NET MVC 웹앱입니다.
갑자기 (일부 NuGet 패키지가 업그레이드 됨) 런타임 중에 다음 오류가 발생하기 시작했습니다.
CS0012 : 'System.Object'형식이 참조되지 않는 어셈블리에 정의되어 있습니다. 어셈블리 '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 웹앱 전용이며 설치된 프레임 워크가 4.6.1 인 Windows IIS에서 호스팅되며 서버에 NET Core가 설치되어 있지 않습니다.
그렇다면 왜 참조를 추가하도록 요청 netstandard합니까? 참조하지 않고 netstandard전체 Windows .NET Framework 4.6.1을 수정하려면 어떻게해야 합니까?
잘 작동했던 이전 커밋을 확인했는데 여전히이 오류가 발생합니다. 따라서 업그레이드되는 NuGet 패키지와 관련이 없습니다. 내 로컬 개발 시스템에 뭔가있는 것 같습니다.
앱을 디렉토리에 게시하고 IIS로 실행하면 작동합니다.
packages.json
<?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.
But I can't find anything on System.Transactions. How can I search what's referencing it?
I think the solution might be 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" />
I realise you're using 4.6.1 but the choice of .NET 4.7.1 is significant as older Framework versions are not fully compatible with .NET Standard 2.0.
I know this from painful experience, when I introduced .NET Standard libraries I had a lot of issues with NUGET packages and references breaking. The other change you need to consider is upgrading to PackageReferences instead of package.config files.
See this guide and you might also want a tool to help the upgrade. It does require a late VS 15.7 version though.
Manually editing the .csproj file and adding the reference below worked for me.
<Reference Include="netstandard" />
Thank you to Fahad Alshaya who suggested it here.
I have run into this before and trying a number of things has fixed it for me:
- Delete a bin folder if it exists
- Delete the hidden .vs folder
- Make sure the 4.6.1 targeting pack is installed
- Last Ditch Effort: Add a reference to System.Runtime (right click project -> add -> reference -> tick the box next to System.Runtime), although I think I've always figured out one of the above has solved it instead of doing this.
Also, if this is a .net core app running on the full framework, I've found you have to include a global.json file at the root of your project and point it to the SDK you want to use for that project:
{
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
Although this is an old thread, I had the same issue today, last week I updated some NuGet packages and although the MVC website worked OK on my dev machine when I published to the testing server it failed.
I read numerous posts but none worked. I finally compared the DLL's in my local bin to those in the testing server and found that the netstandard.dll was not uploaded, once uploaded the website worked OK, not sure why VS2017 web deploy did not publish the DLL.
Just something to look out for in case none of the above work for you.
Deleting Bin and Obj folders worked for me.
I experienced this when upgrading .NET Core 1.1 to 2.1.
I followed the instructions outlined here.
Try to remove <RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion> or <NetStandardImplicitPackageVersion> section in the .csproj.
After upgrading from 4.6.1 framework to 4.7.2 we started getting this error:
"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'." and ultimately the solution was to add the "netstandard" assembly reference mentioned above:
<compilation debug="true" targetFramework="4.7.1" >
<assemblies>
<add assembly="netstandard, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51"/>
</assemblies>
</compilation>
We started getting this error on the production server after deploying the application migrated from 4.6.1 to 4.7.2.
We noticed that the .NET framework 4.7.2 was not installed there. In order to solve this issue we did the following steps:
Installed the .NET Framework 4.7.2 from:
Restarted the machine
Confirmed the .NET Framework version with the help of How do I find the .NET version?
Running the application again with the .Net Framework 4.7.2 version installed on the machine fixed the issue.
Might have todo with one of these:
- Install a newer SDK.
- In .csproj check for Reference Include="netstandard"
- Check the assembly versions in the compilation tags in the Views\Web.config and Web.config.
This issue is based on your installed version of visual studio and Windows, you can follow the following steps:-
- Go to Command Window
downgraded your PCL by the following command
Install-Package Xamarin.Forms -Version 2.5.1.527436- Rebuild Your Project.
- Now You will able to see the required output
'Program Club' 카테고리의 다른 글
| 투표 경쟁에서 사기꾼 사냥 (0) | 2020.11.24 |
|---|---|
| IContainer 해결 (0) | 2020.11.24 |
| 일반적인 루비 관용구 (0) | 2020.11.24 |
| select vs poll vs epoll (0) | 2020.11.24 |
| IIS 7에서 하위 도메인을 설정하는 방법 (0) | 2020.11.24 |