ASP.NET Core 2.0 Failed to load file or assembly System.ServiceModel

I am working on porting an “ASP.NET core web application” that compiles in the .NET Framework 4.6.1 (i.e. the complete infrastructure) to compile on .NET Core 2.0. I have some dependencies that still require a complete framework, but with .NET 2.0, I understand that I can now reference the full assembly builds from the compiled .NET Core 2.0 application.

When I try to start a project, I get the following error:

Failed to load file or assembly 'System.ServiceModel, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089'. The system cannot find the specified file.

I looked through all the NuGet packages and projects that I refer to, and none of them refer to System.ServiceModel.Web, but I'm not sure if this is the same as System.ServiceModel. When I open the projectname.deps.json file located in the bin folder, I see a link to System.ServiceModel.Web, but not to System.ServiceModel in the "Microsoft.NETCore.App/2.0.0" section, which contains the following line : "ref / netcoreapp2.0 / System.ServiceModel.Web.dll": {},

I also poked into the folder "C: \ Program Files \ dotnet \ shared \ Microsoft.NETCore.App \ 2.0.0" and I see the file System.ServiceModel.Web.dll.

I am not doing WCF work, and, as I said, I looked through all the library dependencies that I use, and none of them reference System.ServiceModel.

Anyone else run into this problem? I appreciate any and all ideas that everyone can have.

+16
asp.net-core
source share
2 answers

I solved this problem by installing the Nuget package:

Install-Package Microsoft.Windows.Compatibility 

I used ASP.net Core 2.2, but maybe it works for 2.0v too

+1
source share

In Asp.Net Core, when the Microsoft WCF Associated Web Services Provider is used in connected services, the code generator automatically turns on System.ServiceModel.Duplex, System.ServiceModel.Http, System.ServiceModel.NetTcp, System.ServiceModel.Security'assemblies.,

 <PackageReference Include="System.ServiceModel.Duplex" Version="4.4.*" /> <PackageReference Include="System.ServiceModel.Http" Version="4.4.*" /> <PackageReference Include="System.ServiceModel.NetTcp" Version="4.4.*" /> <PackageReference Include="System.ServiceModel.Security" Version="4.4.*" /> 

In your case, System.ServiceModel.Primitives needs to be added as well. The System.ServiceModel.Primitives assembly includes System.ServiceModel.dll

System.ServiceModel, version = 4.0.0.0 is no longer used.

see also: https://github.com/dotnet/standard/issues/575#issuecomment-380479584.

0
source share

All Articles