Unable to run azure function app in local due error -The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet\'

Abhijit Jadhav (INFOSYS LIMITED) 11 Reputation points Microsoft Vendor
2023-10-23T17:47:41.81+00:00

Unable to run Azure function app in local

Description: Unable to run azure function app in local. I was able to run function app in local till two weeks ago. Suddenly started facing issue in running function app in local. Getting below error in console on running function app in local. Tried multiple solutions suggested on internet. I have tried reinstalling and repairing VS 2022 multiple times. Even deleted all VS and dotnet files post uninstallation of VS and .net core but still no lock.

Below is the error getting in azure function app console when I run function app in local.

A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet'.
Failed to run as a self-contained app.
The application was run as a self-contained app because 'C:\Users\v-abjadhav\AppData\Local\AzureFunctionsTools\Releases\4.57.0\cli_x64\func.runtimeconfig.json' did not specify a framework.
If this should be a framework-dependent app, specify the appropriate framework in 'C:\Users\v-abjadhav\AppData\Local\AzureFunctionsTools\Releases\4.57.0\cli_x64\func.runtimeconfig.json'.
C:\Users\v-abjadhav\AppData\Local\AzureFunctionsTools\Releases\4.57.0\cli_x64\func.exe (process 11232) exited with code -2147450749.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

Please help as I am blocked in function app debugging.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,403 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,249 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,761 Reputation points Microsoft Employee
    2023-10-25T04:30:22.3933333+00:00

    Hello, @Abhijit Jadhav (INFOSYS LIMITED) - This is likely a minor configuration problem due to a mismatch of bitness between the functions host process vs (a) assemblies being loaded (b) reference to installed dotnet (c) and OS version. A few things to verify are as follows:

    If none of the above helps, please share your project setup that repros the issue. Github link or a zip upload should do.


    Please "Accept Answer" if the answer is helpful so that others in the community may benefit from your experience.

    0 comments No comments