I have created an Core 3.1 application that use web services based on .net standrad 2.0.
On local development environment every things works fine. Till I deploy it on UAT 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 a while, I found this :
Answered by zhenlan
First, copy 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 SPSM.dll for build and publish.
<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 ensure the file is in my deployment, but have still the same issue, what is going wrong and how can I fix the issue?
While I made the question, I made some progress and wanted to share answer for those who might face the same issue.
As I understand this is used for web service part of my project, so in my local environment, it is served. But when I deploy it on UAT IIS it does not have this by default.
So adding the file as I did from different places did not help. This might have relation to versioning, no knowledge about that.
The way I fixed it, I just installed the latest NuGet package via NuGet manager to my web application project.
<ItemGroup>
<PackageReference Include="System.Private.ServiceModel" Version="4.7.0" />
</ItemGroup>
And after redeploying on UAT, it worked right a way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.