I've trouble with running my isolated .NET 5 Azure Function on my local computer and Visual Studio 2022. I've next message:
Failed to load the dll from [C:\Users\***\AppData\Local\AzureFunctionsTools\Releases\3.30.1\cli_x64\hostpolicy.dll], HRESULT: 0x800700C1
An error occurred while loading required library hostpolicy.dll from [C:\Users\***\AppData\Local\AzureFunctionsTools\Releases\3.30.1\cli_x64]
C:\Program Files (x86)\dotnet\dotnet.exe (process 15628) exited with code -2147450750.
Press any key to close this window . . .
Here is the code of the project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<!-- Some code here -->
</ItemGroup>
<ItemGroup>
<!-- Some code here -->
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
I've tried these things:
- Adding
<RuntimeIdentifiers>win10-x64;win7-x86</RuntimeIdentifiers>
to thePropertyGroup
tag of the project file _(like on this question Error loading hostpolicy.dll while deploying .NET Core console app to Azure WebJobs) → Didn't work - Setting the path environment variable
C:\Program Files\dotnet\
aboveC:\Program Files (x86)\dotnet\
(like on this article .NET 6 Azure Functions Isolated: An error occurred while loading required library hostpolicy.dll) → Didn't work - Droped and recreated the project → Didn't work
- Switching to Visual Studio 2019 → Working
Why doesn't it work with Visual Studio 2022?