Reputation: 288
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.
Upvotes: 20
Views: 11529
Reputation: 499
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
Upvotes: 11
Reputation: 30665
In Asp.Net Core, when the Microsoft WCF Web Service Reference Provider is used under the connected services, code generator automatically includes 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 occasion, System.ServiceModel.Primitives is needed to be added aswell. System.ServiceModel.Primitives assembly includes System.ServiceModel.dll
System.ServiceModel, Version=4.0.0.0 is not used anymore.
please also see: https://github.com/dotnet/standard/issues/575#issuecomment-380479584
Upvotes: 1