面向net461的ASP.Net Core,由于ConfigurationManager而无法运行

时间:2018-10-19 11:18:52

标签: asp.net-core asp.net-core-2.1

我有一个针对net461的ASP.Net项目(2.1),使用IIS Express在开发环境中运行它时,一切都很好。该项目引用了在.net 4.6.1之上构建的另一个项目。

使用dotnet myAspNetApp.exe,当我尝试访问页面localhost:5000时,我得到:

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request. 
System.TypeLoadException: Could not load type 'System.Configuration.ConfigurationManager' 
from assembly 'System.Configuration, Version=4.0.0.0, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

我已将Nuget程序包System.Configuration.ConfigurationManager添加到ASP.Net项目中,但它不起作用,我将相同的程序包添加到了DLL项目中,但仍然给出了相同的错误。

注意:在IIS中托管应用程序时,它可以正常工作!

这是我的dotnet publish命令:

dotnet publish -f net461 -r win7-x64 -o "d:\app publish"

但是,当将dotnet run与相同的参数一起使用时,它运行良好!

我在这里想念什么?

0 个答案:

没有答案