我在Core3.1上本地运行一个Azure函数v2。函数连接从EventHub读取事件并将数据写入Redis数据库。当连接函数出现错误时
System.Private.CoreLib: Exception while executing function:
One or more errors occurred. (Could not load file or assembly 'System.Memory, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.).
Pipelines.Sockets.Unofficial: Could not load file or assembly 'System.Memory, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. System.Private.CoreLib: Could not load the specified file.在Azure函数之外,相同的Redis连接代码正常工作。
我已经将System.Memory nuget软件包V4.5.3安装到项目中,但没有帮助。在NugetforCore3.1中没有列出System.Memory版本4.2
函数使用启动
[assembly: FunctionsStartup(typeof(...))]项目档案
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
<PackageReference Include="Utf8Json" Version="1.3.7" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Configuration\Configuration.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>怎么了?
发布于 2020-02-04 10:47:55
通过将Azure函数版本更改为项目v3中的项目.csproj文件,解决了这个问题。
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>发布于 2021-03-03 00:11:06
如果问题仍然存在,请验证您使用的是正确版本的Azure (v3),我从nodejs中获取了版本2--也就是说,我在nodejs中安装了版本2,在微软的路径中安装了第3版,但我选择了第一个版本,即nodejs,它一直给我错误,直到我删除nodejs,您可以在nodejs中将其更新到版本3,我想它也能正常工作。
发布于 2020-02-03 14:10:14
您能否尝试将true添加到您的.csproj文件中:
<PropertyGroup>
...
<UseNETCoreGenerator>true</UseNETCoreGenerator>
</PropertyGroup>https://stackoverflow.com/questions/60040890
复制相似问题