Failed to load the dll from [%localappdata%\AzureFunctionsTools\Releases\3.30.1\cli_x64\hostpolicy.dll], HRESULT: 0x800700C1

When Visual Studio 2022 went GA, I jumped on the new shiny and updated (from 2022 Preview) as soon as I woke up. Once done I went back to developing my isolated Azure Function app and when debugging it would not load with the following message:

Failed to load the dll from [%localappdata%\AzureFunctionsTools\Releases\3.30.1\cli_x64\hostpolicy.dll], HRESULT: 0x800700C1

Now HRESULT: 0x800700C1 relates to differences in bitness, but I can’t see how anything had changed compared to when I was running this on 2022 Preview the day before.

Note that this error only happened when running isolated Function Apps; in-process Apps loaded and ran as expected.

I tried plenty of things (re-installing VS 2022 Preview, changing build settings, deleting the azure functions core tools and re-installing), but I was stumped. Given the things I had tried, it seemed like it was something environmental, but I had run out of ideas.

Thankfully, I was able to chat to Vijay Ramakrishnan who pointed me in the right direction:

When following the link mentioned in his tweet, I found that the issue come down to the PATH environment variable, where references to the 32-bit versions of dotnet were above the 64-bit.

All I had to do was swap them around.