Azure函数错误:无法加载文件或程序集"Microsoft.Xrm.Sdk,版本= 7.0.0.0"? [英] Azure function error: Could not load file or assembly 'Microsoft.Xrm.Sdk, Version=7.0.0.0'?
问题描述
我正在执行azure功能并在本地对其进行测试,以便将一些数据添加到Dyanmcis CRM中.当我运行函数时,它会抛出此错误:
I m doing a azure function and testing it locally where it will add some data to Dyanmcis CRM. When I run function it throw this error:
无法加载文件或程序集"Microsoft.Xrm.Sdk,版本= 7.0.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35"或其依赖项之一.系统找不到指定的文件.
请注意,我的代码使用Microsoft.Xrm.Client(版本7),并且具有Microsoft.Xrm.Sdk(版本8.1.0.235).
Please note my code uses Microsoft.Xrm.Client(version 7) and it has Microsoft.Xrm.Sdk (version 8.1.0.235).
请帮助.
推荐答案
问题是由于缺少程序集重定向.通过将Microsoft.CrmSdk.CoreAssemblies
NuGet程序包添加到普通的.Net项目中,并查看添加到app.config
的生成的绑定重定向语句,您可以确切地看到需要哪个程序集重定向.
The problem is due to the missing assembly redirect. You can see exactly which assembly redirect is needed by adding the Microsoft.CrmSdk.CoreAssemblies
NuGet package to a normal .Net project and looking at the generated binding redirect statements added to app.config
.
当前,Azure Functions不支持设置程序集重定向,因此必须使用代码来完成.我使用此博客文章中的代码解决了这个问题:
Currently Azure Functions do not support setting assembly redirects, so it has to be done in code. I solved this problem by using the code from this blog post: How to fix the assembly binding redirect problem in Azure Functions
使用该代码,local.settings.json
看起来像这样:
With that code, local.settings.json
looks like this:
"Values": {
"AzureWebJobsStorage": "",
"AzureWebJobsDashboard": "",
"BindingRedirects": "[ { \"ShortName\": \"Microsoft.Xrm.Sdk\", \"RedirectToVersion\": \"8.0.0.0\", \"PublicKeyToken\": \"31bf3856ad364e35\" } ]"
}
以及在Azure门户中的应用程序设置"中:
and in Application settings in the Azure portal:
[ { "ShortName": "Microsoft.Xrm.Sdk", "RedirectToVersion": "8.0.0.0", "PublicKeyToken": "31bf3856ad364e35" } ]
这篇关于Azure函数错误:无法加载文件或程序集"Microsoft.Xrm.Sdk,版本= 7.0.0.0"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!