[英]Unable to call .NET 4.6.1 project from DotNetCore when published to IIS
I currently have a DotNetCore REST API (targeting v2.1) that references a DotNetStandard project (targeting v2.0). 我目前有一个DotNetCore REST API(针对v2.1),该API引用了DotNetStandard项目(针对v2.0)。 The .NET Standard project has a reference to a .NET Full Framework project (targeting v4.6.1) which makes a call to a Sybase IQ database.
.NET Standard项目引用了.NET完整框架项目(针对v4.6.1),该项目调用Sybase IQ数据库。
This all works perfectly when I am running my application in VS2017 using IIS Express, however once I publish the application and try to call the Api endpoint that references the .NET 4.6.1 application, I get the following error: 当我使用IIS Express在VS2017中运行应用程序时,这一切都可以正常工作,但是一旦发布该应用程序并尝试调用引用.NET 4.6.1应用程序的Api端点,就会出现以下错误:
System.IO.FileNotFoundException: Could not load file or assembly >'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, >?>PublicKeyToken=cc7b13ffcd2ddd51'.
System.IO.FileNotFoundException:无法加载文件或程序集>“ System.Drawing.Common,版本= 0.0.0.0,区域性=中性,>?> PublicKeyToken = cc7b13ffcd2ddd51”。 The system cannot find the file specified.
该系统找不到指定的文件。
The strange thing is that none of my projects or referenced Dlls are referencing System.Drawing.Common (or anything in the System.Drawing namespace). 奇怪的是,我的项目或引用的Dll都没有引用System.Drawing.Common(或System.Drawing命名空间中的任何内容)。 All the other functionality works as expected.
所有其他功能均按预期工作。
I have tried manually adding the System.Drawing.Common.dll using Nuget (the latest version is 4.5.1), but this doesn't resolve the problem. 我尝试使用Nuget(最新版本为4.5.1)手动添加System.Drawing.Common.dll,但这不能解决问题。 After adding the Nuget package, I tried adding an assembly binding redirect to the web.config in the published folder:
添加Nuget程序包后,我尝试将程序集绑定重定向添加到发布文件夹中的web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Drawing.Common" culture="neutral"
publicKeyToken="cc7b13ffcd2ddd51" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.6.26919.2" />
</dependentAssembly>
</assemblyBinding>
</runtime>
But the error still persists. 但是错误仍然存在。
Does anyone have any ideas on what might be causing this? 是否有人对造成此问题的原因有任何想法?
Lex Li's answer was the correct one. Lex Li的答案是正确的。 I changed the target framework for the Api application to net471 and it now works as expected.
我将Api应用程序的目标框架更改为net471,现在可以正常使用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.