I have created a Core 3.1 application that uses web services based on .net standard 2.0.
In the local development environment, everything works fine. Until I deploy it on UAT (IIS) I get the following exception:
Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.ServiceModel, Version=4.1.2.4, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Private.ServiceModel, Version=4.1.2.4, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at MyNameSpace.Service.TheService..ctor()
After researching for a while, I found this:
Answered by Zhen Lan
First, copy the file
%USERPROFILE%\.nuget\packages\system.private.servicemodel\4.4.2\runtimes\unix\lib\netstandard2.0\system.private.servicemodel.dll
to the root of your function app. If file is not found, you can download the nuget package from nuget.org.Then, copy/paste below to your project's .csproj file. It will include S.P.SM.dll for build and publishing.
<ItemGroup> <None Update="System.Private.ServiceModel.dll"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> </ItemGroup> <Target Name="CopySPSM" BeforeTargets="Build"> <Copy SourceFiles="System.Private.ServiceModel.dll" DestinationFolder="$(OutputPath)\bin" /> </Target>
I have also checked Protobuf-net has missing dependency System.Private.ServiceModel and Could not load file or assembly 'System.Private.ServiceModel' in Azure Function v2 with out much progress.
I have followed the answer and ensured the file is in my deployment, but have still the same issue, what is going wrong and how can I fix the issue?