Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

.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. #575

Closed
WalterEbbers opened this issue Nov 7, 2017 · 22 comments

Comments

@WalterEbbers
Copy link

WalterEbbers commented Nov 7, 2017

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

@JonesCola
Copy link

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....

@joperezr
Copy link
Member

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.

@WalterEbbers
Copy link
Author

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

@joperezr
Copy link
Member

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

@JonesCola
Copy link

JonesCola commented Nov 10, 2017

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

@shmao
Copy link

shmao commented Nov 10, 2017

@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

@joperezr
Copy link
Member

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

@shmao
Copy link

shmao commented Nov 10, 2017

The latest build from MyGet contains the shim. For example, https://dotnet.myget.org/feed/dotnet-core/package/nuget/System.ServiceModel.Primitives/4.5.0-preview2-25910-01

@joperezr
Copy link
Member

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.

@shmao
Copy link

shmao commented Nov 10, 2017

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.

@zhenlan
Copy link
Member

zhenlan commented Nov 10, 2017

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

@WalterEbbers
Copy link
Author

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

Thnx again all :)

@zhenlan
Copy link
Member

zhenlan commented Nov 21, 2017

@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

@WalterEbbers
Copy link
Author

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.

@shmao
Copy link

shmao commented Nov 21, 2017

@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.

@WalterEbbers
Copy link
Author

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

@shmao
Copy link

shmao commented Nov 23, 2017

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.

@WalterEbbers
Copy link
Author

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

Thnx all for the help!

@tompartridge
Copy link

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

@zhenlan
Copy link
Member

zhenlan commented Apr 11, 2018

@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?

@ArmanHayots
Copy link

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'.'

@BasilKosovan
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants