简体   繁体   English

发布到IIS时无法从DotNetCore调用.NET 4.6.1项目

[英]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.

相关问题 当我在 IIS 上发布 asp net core 5 项目时出现错误 - when I published asp net core 5 project on IIS it has an error 从.Net 4.6.1单元测试引用.Net标准项目时缺少方法异常 - Missing Method Exception When Referencing .Net Standard Project From .Net 4.6.1 Unit Test 无法在引用 .Net 标准库的已发布 .Net 4.6.1 项目中加载文件或程序集“System.ComponentModel.Annotations” - Could not load file or assembly 'System.ComponentModel.Annotations' in published .Net 4.6.1 project referencing .Net Standard library 当从 Web API 项目调用时,Polly 在 .NET 框架 4.6.1 上无限期地等待线程 - Polly waits the thread for an indefinite amount of time on .NET Framework 4.6.1 when called from a Web API project 在 Dot Net 4.6.1 中运行测试项目时,SQLitePCLRaw 抛出 TypeInitializationException - When running test project in Dot Net 4.6.1, SQLitePCLRaw throws TypeInitializationException C# package for .NET 当项目使用.NETFramework 4.6.1 - C# package for .NET when the project uses .NETFramework 4.6.1 .Net 4.6.1 项目中对 exe 的引用 - Reference to exe in a .Net 4.6.1 project System.DllNotFoundException:发布到IIS时无法加载DLL&#39;oci&#39; - System.DllNotFoundException: Unable to load DLL 'oci' when published to IIS Asp.NET 发布到 IIS 服务器时显示“目录无效” - Asp.NET shows "The Directory is invalid" when published to IIS server 发布到IIS 7.5时ASP.NET Core 404错误 - ASP.NET Core 404 Error When Published to IIS 7.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM