从 azure webjob 调用单独的 dll 上的方法时出错

Getting error calling a method on a separate dll from azure webjob

我的 Azure 环境中有一个网络作业 运行。我在单独的 dll 中调用 class 上的方法。但是出现以下错误:

无法加载文件或程序集'Microsoft.WindowsAzure.ServiceRuntime, Version=2.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

我是否也需要在单独的项目上安装 azure sdk?

有人可以澄清一下吗?

谢谢

当您使用的库引用旧版本的 dll 并且新版本随您的 webjob 一起部署时,可能会出现此问题。

您可以在 app.config 中添加绑定重定向,如本页所述:https://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx

检查您在项目中引用的 Microsoft.WindowsAzure.ServiceRuntime 版本,只需在 app.config 中添加一行:

<dependentAssembly>
    <assemblyIdentity name="Microsoft.WindowsAzure.ServiceRuntime"
      publicKeyToken="31bf3856ad364e35"
      culture="en-us" />
    <bindingRedirect oldVersion="2.4.0.0" newVersion="YOUR_VERSION" />
  </dependentAssembly>

希望这对您有所帮助,

朱利安