Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core 2.0 Could not load file or assembly System.ServiceModel

Tags:

asp.net-core

I am working on porting an "ASP.NET Core Web Application" that was compiling under the .NET Framework 4.6.1 (i.e. full framework) over to compiling against .NET Core 2.0. I have some dependencies which still require the full framework but with .NET 2.0 my understanding is that I can now reference full framework assemblies from within a .NET Core 2.0 compiled application.

When I attempt to run the project, I get the following error:

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

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

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

I'm not doing any WCF work and as I stated I've looked at all the dependencies of the libraries I'm using and none of them appear to be referencing System.ServiceModel.

Has anyone else run into this issue? I appreciate any and all insights anyone might have.

like image 966
Devin Michael Avatar asked Aug 22 '17 17:08

Devin Michael


1 Answers

I solved this problem installing the Nuget package:

Install-Package Microsoft.Windows.Compatibility

I was using ASP.net Core 2.2 but maybe works for 2.0v too

like image 192
david.q Avatar answered Oct 11 '22 17:10

david.q