An error occurred while loading required library hostpolicy.dll with Azure Function With Visual Studio 2022

Viewed 1276

I've trouble with running my isolated .NET 5 Azure Function on my local computer and Visual Studio 2022. I've next message:

Visual Studio error message

Microsoft Visual Studio Debug Console

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:

  1. Adding <RuntimeIdentifiers>win10-x64;win7-x86</RuntimeIdentifiers> to the PropertyGroup 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
  2. Setting the path environment variable C:\Program Files\dotnet\ above C:\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
  3. Droped and recreated the project → Didn't work
  4. Switching to Visual Studio 2019 → Working

Why doesn't it work with Visual Studio 2022?

0 Answers
Related