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

问题描述 投票:0回答:1

我一直在我的azure函数应用程序中使用azure函数V2(.net核心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的情况下,我如何无法得到该错误?是否有相同的分辨率?

azure asp.net-core azure-functions asp.net-core-2.1 servicemodelex
1个回答
0
投票

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

希望有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.