无法在 Azure Function v2 中加载文件或程序集“System.Private.ServiceModel”

Raz*_*itu 7 c# azureportal asp.net-core azure-functions azure-durable-functions

我使用了 v2 azure 函数(持久函数)和调用服务的自定义 dll(.net core 2.2),但出现以下异常:

无法加载文件或程序集“System.Private.ServiceModel,版本=4.1.2.4,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a”

在调试过程中,我无法进入该方法,并且在不让我进入该方法的情况下抛出异常,我不知道究竟是什么试图访问该库。将 .nuget 中的包手动放入 bin 文件夹中不起作用,奇怪的是,如果使用示例 C# 函数运行相同的代码,它会起作用。

Nad*_*ard 8

固定 Nuget 安装或更新 System.Private.ServiceModel

安装包 System.Private.ServiceModel -Version 4.7.0

https://www.nuget.org/packages/System.Private.ServiceModel/


Pau*_*ica 6

这个问题在这里有详细说明:https : //github.com/dotnet/wcf/issues/2824

我如何解决它是下载nuget System.Private.ServiceModel

并将以下内容添加到我的 .csproj

<Target Name="CopySPSM" BeforeTargets="Build">
<Copy SourceFiles="$(USERPROFILE)\.nuget\packages\system.private.servicemodel\4.5.3\runtimes\win\lib\netstandard2.0\System.Private.ServiceModel.dll" DestinationFolder="$(OutputPath)\bin" />
</Target>
Run Code Online (Sandbox Code Playgroud)


Q.R*_*Rey 0

尝试检查您的cs.proj是否实现了System.Private.ServiceModel.dll,如果不是这种情况,您可以参考此解决方法: https: //github.com/dotnet/wcf/issues/2824