Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Private.ServiceModel missing in azure app service at runtime

I am attempting to deploy an asp.net core 2.1 webapp to an azure app service. The webapp utilizes a wcf service and therefore contains references to wcf. Everything runs fine at compile and on developer machines. However when it is deployed to an azure app service the webapp fails to start up. It throws an error

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

I have tried publishing the app both self-contained and framework dependent. Is there some special way I need to include or reference this package?

like image 801
JeffreyABecker Avatar asked Jun 07 '18 16:06

JeffreyABecker


1 Answers

I was encountering a similar solution after trying to use the SoapCore NuGet package in ASP.NET Core 2.1 application. Ran fine locally on Windows 10 but gave the exact same stack trace as the original poster after I published to Azure. The following GitHub issue helped me understand the problem:

https://github.com/dotnet/wcf/issues/2349

For me, SoapCore was referencing System.ServiceModel.Http 4.4.0, and it had a dependency on System.Private.ServiceModel 4.4.0. If you download the NuGet package and open the nupkg file for System.Private.ServiceModel 4.4.0 and observe the "runtimes" sub-folder, you'll see it only lists "win7" and "unix". Azure appears to be looking for runtimes "win-x86" or "win-x64", and the GitHub issue above explains how those RID's were not included by the "win7" RID. Seeing that the issue was closed, I downloaded the System.Private.ServiceModel 4.5.0 to inspect the "runtimes" sub-folder and see that it was changed from "win7" to "win" just like mentioned in the GitHub issue.

To solve my issue, I directly added a dependency for System.ServiceModel.Http 4.5.0 to my project. This included the newer dependency for System.Private.ServiceModel 4.5.0 and Azure would recognize the "win" runtime properly to ensure the necessary DLL was included with my application when published.

like image 134
HgCoder Avatar answered Oct 14 '22 06:10

HgCoder