visual-studio - 无法评估扩展元数据的 'Cosmos.CRTCompat.dll'。异常消息: Bad IL format

标签 visual-studio azure azure-functions

我在 Visual Studio 2019 中发布 azure 函数时收到以下警告。

Could not evaluate 'Cosmos.CRTCompat.dll' for extension metadata. Exception message: Bad IL format. Could not evaluate 'Microsoft.Azure.Documents.ServiceInterop.dll' for extension metadata. Exception message: Bad IL format.

我在一个空白项目中尝试了相同的操作,但出现了相同的警告。

我在 VS Code 中看到同样的问题

C:\Users\pankaj.ra.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.5\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(63,5): warning : Could not evaluate 'Cosmos.CRTCompat.dll' for extension metadata. Exception message: Bad IL format.

我的函数项目文件

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="4.1.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.5" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

最佳答案

由于您在空白项目中遇到相同的错误,因此该问题很难解决。我创建了一个空白函数并在本地和 azure 中运行良好。

首先,清理所有 nuget 缓存(本地和全局)并恢复所有内容。

dotnet nuget locals all --clear

这很可能是因为处理器架构不匹配:例如,在使用 32 位时加载 64 位程序集会导致此情况

If your application uses 32-bit components, make sure that it always runs as a 32-bit application.
Make sure that you are not using a component that was created with a different version of the .NET Framework.
Make sure that the file image is a valid managed assembly or module.

并且,就列表中的第一项而言:

If the Platform target property for your application project is set to AnyCPU, the compiled application can be run in either 64-bit or 32-bit mode. When it runs as a 64-bit application, the just-in-time (JIT) compiler produces 64-bit native code. If the application depends on a 32-bit managed or unmanaged component, that component will fail to load in 64-bit mode. To correct this problem, set the project's Platform target property to x86 and recompile.

更多详情可以引用这个article .

关于visual-studio - 无法评估扩展元数据的 'Cosmos.CRTCompat.dll'。异常消息: Bad IL format,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60757880/

相关文章:

visual-studio - Visual Studio 正在等待内部操作完成

c++ - 带有 CUDA 的 Visual Studio 2017 无法打开包含文件 'cuda.h'

visual-studio - DSOFramer 在另一个窗口中关闭 Excel 文档。如果文件中未保存数据,dsoframer 无法打开并显示 "Attempt to access invalid address"

azure - 如何使用 bicep 为我的 azure 函数创建访问策略?

c# - Intellisense 窗口有输入字段,不占用空间

postgresql - 超时已过期 : Connecting Azure Postgres using local pdAmin

azure - 使用 REST API 从 Azure Blob 容器获取所有文件,我已经尝试过此代码,但遇到 403 错误

azure - Bicep 将参数添加到自动化帐户作业计划

asp.net-core - 通过 Azure Function 注入(inject) DbContext 时无法访问已处置的对象

azure - 如何从 Azure Function 中删除 Azure 表存储条目?