Standard: .NET Standard 2.0 / .NET Framework 4.6.1 Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

Created on 7 Nov 2017  路  22Comments  路  Source: dotnet/standard

Hi,
I have a .NET Standard 2.0 library which references a few NET 4.6.1 libraries.
The .NET Standard library will be used in a .NET Core web application.
The .NET 4.6.1 Framework uses library 'System.ServiceModel.dll' for WCF calls.

I try to do the following.
My .NET Core webapp goes to the .NET Standard library which calls something from my .NET Framework 4.6.1 project. But at that moment 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.'

The 'System.ServiceModel.dll' is referenced as a assemblyreference in the .NET Standard project and the .NET Core webapp.

I really thought that this would work but sadly it doesn't. Is this a issue with the .NET libraries?
Do i need to change things in my .NET Standard / Core project?

Thnx in advance :)

Walter

Most helpful comment

We currently do not have plan to add this API in any of the future release. But we would definitely consider to add the API if we see more user usage.

All 22 comments

I am also having this problem. It seems there is a lack of information on this specific issue. I stopped referencing the .net 4.6.1 version of System.ServiceModel and instead referenced the System.ServiceModel.Primitives, System.ServiceModel.Http, System.ServiceModel.Web and System.ServiceModel.Security nuget packages that are supposed to be compatible. This did not work for me as the WsHttpBinding does not seem to exist anywhere. I thin I am going to have to downgrade my project to use the 4.6.1 framework instead of the .net standard. Unless someone can assist....

Did you add a reference to the Service Model packages in your .NET Core project? I'm not sure exactly which ServiceModel Api you rely on, but the available packages are:

System.ServiceModel.Duplex
System.ServiceModel.Http
System.ServiceModel.NetTcp
System.ServiceModel.Primitives
System.ServiceModel.Security

They will contain the .NETCore implementation of the API plus also the shim of System.ServiceModel.dll that you will need in order to be able to correctly type forward the type.

I'll will check back on monday, but from what i remember, i linked the libraries to my .NET Core and .NET Standard project.

I know that the System.ServiceModel.dll shim was added recently, so it's possible that the version of the packages that you are referencing don't have it. Can you check if you are referencing the latest released packages for ServiceModel? cc: @shmao

I am not using net.tcp or duplex so I did not add those. I am using the most recent nuget packages that are available and the include pre-release flag was checked

@joperezr The System.ServiceModel.dll shim was added in System.ServiceModel.Primitives and shipped with UWP6.0. For .Net Standard, however, we haven't shipped any packages including the shim yet. I expect the shim to be shipped in the next .Net Standard release.

/cc: @zhenlan

can you confirm which version of the Primitves package contain the shim? Even if they are prerelease it's fine.

yeah but what about nuget.org? since this is for a customer it's better to point them to shipped packages and not daily builds.

We haven't shipped any packages containing that shim on nuget yet. It was only shipped as part of the meta-package for UWP6.0.

The System.ServiceModel.dll shim has been ported to 2.0 and will be released to nuget.org sometime soon (weeks) (dotnet/wcf#2375).

Thank you all!
I will keep an eye out for the release with the System.ServiceModel support!

Thnx again all :)

@WalterEbbers we just released to nuget.org an update of System.ServiceModel.Primitives package, which contains the System.ServiceModel.dll shim you would need. Can you please update your project to reference this package and see if it solves your problem?

https://www.nuget.org/packages/System.ServiceModel.Primitives/4.4.1-servicing-25917-01

Thank you for the update!
Unfortunately, in my downsized test project, i'm now getting the following errormessage:

System.TypeLoadException: 'Could not load type 'System.ServiceModel.Channels.RemoteEndpointMessageProperty' from assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.'

I made a small test solution, with a .net core console app, .net standard 2.0 library and a .net framework 4.6.1 project.

The .NET Core and .NET Standard project both reference the new nuget package.

The stripped down .NET Framework 4.6.1 only has a method wich calls the OperationContext.Current.IncomingMessageProperties with RemoteEndpointMEssageProperty.Name as a key.

This fails.

@WalterEbbers thanks for trying the package. Unfortunately, type System.ServiceModel.Channels.RemoteEndpointMessageProperty is not available on .Net Core, see https://apisof.net/catalog/System.ServiceModel.Channels.RemoteEndpointMessageProperty. Therefore, the shim included in the new package cannot help in this case.

Thnx for the reply.
Is there a chance it will be supported in the future?

We currently do not have plan to add this API in any of the future release. But we would definitely consider to add the API if we see more user usage.

I see, understandable :)
The issue can be closed then :)

Thnx all for the help!

I was running into this problem with the Could Not Load System.ServiceModel Assembly exception while connecting to .NET Framework 4.0 libraries from a console .NET Core 2.0 project, and the Nuget System.ServiceModel.Primitives package on my .NET Core 2.0 project resolved it.
https://www.nuget.org/packages/System.ServiceModel.Primitives/4.4.1-servicing-25917-01

@tompartridge there is a stable version released already https://www.nuget.org/packages/System.ServiceModel.Primitives/4.4.1.

If this still does not work for you, could you please open a new issue at WCF repo (https://github.com/dotnet/wcf/issues/new) and share a step by step repro?

I think that's related.
System.TypeLoadException: 'Could not load type 'System.ServiceModel.WS2007FederationHttpBinding' from assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.'

@shmao will be good to see this package in .netstandard

Was this page helpful?
0 / 5 - 0 ratings

Related issues

praeclarum picture praeclarum  路  5Comments

chrisaut picture chrisaut  路  3Comments

virzak picture virzak  路  4Comments

ghost picture ghost  路  4Comments

KexyBiscuit picture KexyBiscuit  路  3Comments