Sudden "Failed to load hostfxr.dll" - c#

I'm working in a solution that has several .net core (as well as standard and framework) projects.
Up until this morning, when I debugged a .net core project it would launch fine. This morning, that broke. I get an error stating
The library hostfxr.dll was found , but loading it from XXX failed
When I build the project, and try running the EXE, the same thing
happens.
When I add a new project to the solution, it works fine.
When running the built debug version on another machine (with the
.net core SDKs), I get the same issue
When I change the project to
run in Release, it works fine.
When I change the project to run in Debug, and 32bit, it works fine
When I build the project via cli/dotnet build -c Debug, it works.
When I build the project via Visual Studio, in Debug, in 32bit it works.
When I build the project via Visual Studio, in Debug, in 64bit it doesn't work.
I've cleaned/rebuild the project.
I've restarted
I've updated my Visual Studio
I've removed and reinstalled the .net core SDK
Any suggestions on what happened and how I can fix it?
Im running Windows 10 and Visual Studio 2019
UPDATE
After performing my Windows updates overnight, it no longer works when I use dotnet build.

So it turns out that a clean/rebuild doesnt completely clean the solution.
After I deleted the obj and bin folders, and restarted VS, the problem was resolved.

In our case (with a build server on Windows Server 2019), it was a case of user rights.
The user that executed the build process (Jenkins), did have access to the folder where hostfxr.dll was located, but required to be an administrator on the build server.
Test the process running under the name of an admin, before re-installing frameworks or installing any Windows Updates.

Related

The program has exited with code 2147516551 (0x80008087)

I have a solution that was compiling and running fine in Visual Studio 2022. I added another project to the same solution, did some work on the new project and then checked it all into Devops. Now, everything compiles fine. I can "publish" to a folder and get the EXE and it runs. But I CAN'T run it in Visual Studio or by trying to run the EXE in the bin folder structure. When I click the run button in VS, I get:
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use .NET Core. This may be expected if the target process did not run on .NET Core.
The program '[21684] Enable Instant Book.exe' has exited with code 2147516551 (0x80008087).
Now, this is a Winforms application targeting .Net 6.0 on Windows. So I'm not sure why it's suddenly throwing this error nor why it says "CoreCLR" in the error when I'm not targeting Core. I'm so frustrated with it that I'm thinking of dumping it all and redoing it in VS 2019 with .Net 4.x. But I thought I would see if any of you knew some magic to get it to return to a working state first.
Some of the things I've tried:
Clean and rebuild
Remove all projects except the very first one that I know was working and rebuild
Close and reopen VS / Reboot PC
Delete everything in "bin" folder and rebuild
Changing the compile from "Any CPU" to x64
Any ideas?

Trying to run an Azure Function App locally from Visual Studio 2017 gives a 'func.exe does not exist' error

I have created a new Azure Function app with an Http Trigger in Visual Studio 2017 (which I have just updated to v15.8.4).
Using the generated function, when I try to run it I just get a message box with the error
The debug executable "C:\Users\Paul\AppData\Local\AzureFunctionTools\Releases\2.5.2\cli\func.exe" specified in the 'FunctionApp1' debug profile does not exist.
Sure enough there is no func.exe at that location, just a func.dll.
The file C:\Users\Paul\AppData\Local\AzureFunctionTools\Releases\1.3.0\cli\func.exe does exist.
I have successfully run an Azure function locally before but I assume updating Visual Studio a few times has broken something.
How can I get this working?
I Deleted AzureFunctionsTools and azure-functions-core-tools from C:\Users\ {YourUser} \AppData\Local. And ran the solution again it downloaded the same tools and then executed without errors.
I eventually got this to work by changing the settings in the Debug screen.
I changed Launch from Project to Executable
I set Executable to C:\Users\xxxx\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.exe
I changed Application arguments to start
I changed Working Directory to Sourcedirectory\FunctionApp1\FunctionApp1\bin\Debug\netstandard2.0
I would still love to know where the Project settings were getting their values from though...
In my similar case after installing Visual studio 2019 16.11.2 in a new Win 10 S.
I had already AzureFunctionsTools version 3.23.5 installed with func.exe inside the cli folder (without_x64 suffix)
But my newly installed VS 2019 was looking for func.exe in a similar path with only one difference that was (_x64 suffix after cli).
C:\Users\[username]\AppData\Local\AzureFunctionsTools\Releases\3.23.5\cli_x64
After getting no result trying a other solutions mentioned here I finally renamed the existing cli folder to cli_X64 and it worked
How can I get this working?
In your case, it seems that there is no azure function tools v2 , please have a try to install it.
npm i -g azure-functions-core-tools#core --unsafe-perm true
Please also try to update the [Azure functions and Web Jobs tools] to latest version
tool->Extensions and updates
And then try to run the azure function, if there is no corrosponding version it will download it automatically.
Test Result
Update
Check the function tools from the path
C:\Users\{userName}\AppData\Local\AzureFunctionsTools\Releases
I am able to get this working just by targeting .Net Standard 2.0.
Just change to netstandard2.0 in the project file.
Application Settings
Debug Settings
There is no need of providing a path to the func.dll.
I was just having on a fresh install of Visual Studio 2019 (had to uninstall 2017), and it was irritating me to no end.
I have found a solution to the problem, but no reason as to why this problem happened nor why Visual Studio deemed it necessary to make it so hard to fix things (they have no option of installing or reinstalling Azure Functions Tools in VS 2019 or even outside of it).
Solution:
Find a way to download the release. I used npm: npm install -g azure-functions-core-tools#3
(-g is global but you can install it locally, #3 will install the latest 3.x.x)
Replace the entire contents of C:\Users\<username>\AppData\Local\AzureFunctionsTools\Releases\3.4.1\cli_x64 with the version you installed.
For me, it was all the files in \node_modules\azure-functions-core-tools\bin.
What worked for me is combination of above two answers .
Same error I also faced due to anti-virus but can't modify anti-virus since it can be changed by IT Security/networking team and process is time-taking & long process. Another workaround is :
Install azure-functions-core-tools via npm
npm install -g azure-functions-core-tools#3
Change Executable & Working Directory in Debug settings for azure Project settings
Working Directory : C:\<Project path>\bin\Debug\netcoreapp3.1
Executable : C:\Users\<username>\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\func.exe

Visual Studio 2017 Enterprise cannot start ASPNet Core application

I have the latest VS2017 Enterprise.
I have 'ASP.NET and web development' workload installed.
Also I have .NET Core SDK both versions 32/64 bits.
I create new ASP.NET Core Web Application from template.
When I try to 'Start without debugging' I got an error - "The Project doesn't know how to run the profile IIS Express"
At the same time this project can be run successfully from command line
dotnet run
I know that similar question exists but all suggestions from it are not helpful in my case
Visual Studio 2015 can't start IIS Express
I reinstalled my VS from scratch and now it works
try to remove the vs folder and try to run the project
The .vs is a hidden folder so you have to enable the Show hidden files
PS: close visual studio before removing the folder

VS2010 Building Installer Failing on Setup

I have created an application in C# visual studio 2010.
The application works fine in debug mode and builds successfully. The application has three aspects to the solution. When i build and deploy the setup file i get an error on the install as soon as i click install in the steps.
The error says Installation Incomplete, The installer was interuppted before InvoiceProcess could be installed. You need to restart the installer to try again.
When i restart i get the same error.
Both the development machine and machine to deploy on are both 64 bit windows 10.
What could be causing this?
One of the possible reasons that it is not getting installed because IIS6 management compatibility is not configured on IIS.
Visual Studio 2010 installer still targets the older version of IIS (means IIS6) although IIS7 was publicly available in 2008. That’s why IIS6 compatibility is required.

targeting amd64 is not compatible with the project's target platform x86 c#

I'm working on a .NET application (C#) using VS 2013 in 64-bits plat-form. When I deploy it I got this message.
targeting amd64 is not compatible with the project's target platform x86 setup project
Building not success
The problem comes from CrystalReport I think. Maybe I'll need a dll file target X86. What shall I need to do ?
Had a frustrating hour getting the same error message when Visual Studio was trying to build an installer, but it was targeting a different dll.
The solution was to just close and open Visual Studio.
I had this problem with Visual Studio 2010. The project had no notable changes in a while, but suddenly this error started showing. Closing Visual Studio, deleting every 'bin' and every 'obj' folder in the project, opening Visual Studio, then rebuilding solved the problem.
In Visual Studio. On the menu bar, choose Build, Configuration Manager. Here you can configure your project for the target environment.
You will need to configure the project itself to have the same target environment (amd64) as the build and the libraries you're using.

Categories