Azure Functions V2 +(.net Core 2.1)的服务模型组装错误

我一直在我的azure函数应用程序中使用azure函数V2(.net core 2.1)。 我一直在我的函数App中使用System.ServiceModel.Primitives nuget,该函数在其中使用了ServiceBusEnvironment包。

我能够编译代码并运行功能。 调用该函数时,出现此运行时错误。

   Could not load type 'System.ServiceModel.Channels.IBindingRuntimePreferences' 
from assembly 'System.ServiceModel,Version=4.0.0.0'

我用Google搜索了很多东西。但没有运气。

然后我尝试通过将我的azure函数从V2降低到V1(.net Framework 4.7),它又开始工作了。

在V2的情况下,我需要知道我在做什么错。在V2的情况下,我如何无法得到该错误?有相同的分辨率吗?

henghbing 回答:Azure Functions V2 +(.net Core 2.1)的服务模型组装错误

Microsoft现在已经在NuGet上以软件包的形式提供了相关程序集。

System.ServiceModel.Primitives是基本软件包;如果需要,将其他添加到您的项目中。

enter image description here

我相信,如果要加载System.ServiceModel.Channels,则如果项目不是依赖项,则需要在项目中安装**System.ServiceModel.Http**, 安装正确版本的System.ServiceModel.Http后,看看它是否可以工作。

由您自己将相同的“ System.ServiceModel.Http” NuGet包添加到您的应用程序项目中,以便可以正确地对其进行引用。您可以使用“ Manage NuGet Package”菜单项或仅更新packages.config文件来完成此操作,例如

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="System.ServiceModel.Http" version="4.4.1" targetFramework="net461" />
  <package id="System.ServiceModel.Primitives" version="4.4.1" targetFramework="net461" />
</packages>

其他参考:

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

希望有帮助。

,

经过大量搜索之后,我才得出一个解决方案,即azure函数v2基于.net核心,并且服务总线库无法与v2(.net core)一起很好地工作

我发现的唯一解决方案是切换到V1,因为Azure函数V1支持.net FrameWork类。

本文链接:https://www.f2er.com/3152987.html

大家都在问