我有一个用于以下目的的DLL:Asp.net网站和WinForms,我在使用它时遇到问题。Net Core 3.1DLL正在从web.config读取数据例如:
apiKey = ConfigurationManager.AppSettings["MyApiKey"];
当我尝试使用.Net Core运行它时,出现此错误:
System.IO.FileNotFoundException:'无法加载文件或程序集'System.Configuration.ConfigurationManager,版本= 4.0.3.0,文化=中性,PublicKeyToken = cc7b13ffcd2ddd51'。系统无法找到指定的文件。'
当我安装NuGet System.Configuration.ConfigurationManager
我收到此错误:
System.Configuration.ConfigurationErrorsException:'配置系统无法初始化'ConfigurationErrorsException:无法识别的配置节system.serviceModel。(P:\ Projects \ MyProjectName \ bin \ Debug \ netcoreapp3.1 \ MyDllName.dll.config第48行)
第48行,我有此肥皂绑定:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MyTestServiceSoap">
<security mode="Transport" />
</binding>
<binding name="MyTestServiceSoap1" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://ws.MyTest.com/ws/test/service.asmx" binding="basicHttpBinding" bindingConfiguration="MyTestServiceSoap" contract="MyTestServiceSoap.MyTestServiceSoap" name="MyTestServiceSoap" />
</client>
</system.serviceModel>
问题是我还必须更改此设置(第48行),以便DLL可以正常工作。请注意,我对“调试和发布”有不同的设置。
请告知
为了使.NET Core应用程序与WCF服务进行通信,您需要通过NuGet安装System.ServiceModel.Primitives
。
首先安装该程序,然后查看是否可行。您可能还需要NuGet安装System.ServiceModel.Http
这里是github页面