"GenerateResource" task CLR2 runtime error
Asked Answered
A

8

35

My app keeps getting this error (I'm using VS 2013, VB.NET, and Windows 8.1, by the way):

Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR2" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files (x86)\MSBuild\12.0\bin\MSBuildTaskHost.exe" exists and can be run.

The app is for .NET 3.5 (3.5 and lower versions get me this error). I try to run the app again. Sometimes, it works; sometimes, the error comes back.

I already tried looking up for answers at Google and the answer they gave me turned out to be: "Your build's username is too long" (they said that 20 characters or more cause the error), but it's not true. My user name is 5 characters only. Anyway, I don't think my build's username's length has anything to do with it; it makes no sense.

Does anyone know what is wrong with 3.5 and lower versions? Thank you.

Abbacy answered 25/2, 2015 at 0:25 Comment(4)
I've been seeing this error as well, just in the last few weeks. It repeats poorly. It is not your app, only happens when you build. Haven't seen it since the last time I rebooted. So, reboot first.Standley
@HansPassant Thank you, it just had this worry that it could create problems to my users after its release.Abbacy
I believe the google search being referenced is for this page: connect.microsoft.com/VisualStudio/feedback/details/758772/…Warthman
Just noting it hasn't happened in vs2015, and repeatedly trying a rebuild shows me how much faster the VB compiler in VB is!Moye
R
49

This fixed the issue on my machine:

To resolve it, go to your csproj file and add the following line under the default property group:

<PropertyGroup>
    ...
    <DisableOutOfProcTaskHost>true</DisableOutOfProcTaskHost>
</PropertyGroup>

Found here.

Ropy answered 3/9, 2015 at 8:14 Comment(2)
Yes, this worked for us in Windows 10 + Visual Studio 2012 v11.xxxx Not sure what the cause is.Grigsby
Cause, I believe, is related to not having permission for Visual Studio to execute some of these helpers in parallel. This started coming up for half of my staff suddenly, specifically the half that had been moved to a new domain controller whose IT Wizards dictated that developers can't have admin rights to their own machines. This Answer solved the problem.Knight
M
14

Clean and rebuild solution worked for me.

Magpie answered 30/12, 2015 at 11:10 Comment(1)
I was trying out a downloaded solution and as the OP mentioned the solution was building sometimes and other times not. As you suggested, I cleaned the solution and it started building once again. Thank youBrume
U
3

Adding this in each project is a cumbersome task. So you can set it in the environment variables.

Click Start>> Right-click Computer >> Properties >> Advanced system settings >> Click Environment Variables button to open the dialog, then under the System variables section, click New… button, type the Variable name = DISABLEOUTOFPROCTASKHOST, and type the Variable value = 1, then click Ok.

More here

Unwilled answered 12/6, 2018 at 11:26 Comment(0)
M
1

I'm using VS 2013, VB.NET, and Windows 10, 64 bits, by the way

Just change in XML properites , Services : .NET Framework 4.6 instead .Net Framework 2.0 (Default)

and working fine for me.

Moonfaced answered 27/6, 2019 at 22:29 Comment(0)
C
0

I try adding the follow but didn't works

  <PropertyGroup>
        ...
        <DisableOutOfProcTaskHost>true</DisableOutOfProcTaskHost>
    </PropertyGroup>

this solve this issue for me, adding the same as enviroment Variable

DisableOutOfProcTaskHost=true

Cymbre answered 8/3, 2017 at 19:21 Comment(0)
O
0

I encountered this error when trying to build a sample solution that was included in some software that was installed under C:\Program Files\. Visual Studio prompted me to restart with elevated privileges (as it does when opening a solution in a "secure" location), however the build failed with the OP's error message.

Copying the solution to a "normal" folder (e.g. C:\Temp) solved it for me.

Obscurant answered 18/10, 2017 at 10:5 Comment(0)
B
0

I tried opening an old VS2010 vb project inside VS2013 recently and just ran into this problem. I got around it this way:

  1. I went to the vb project's properties page
  2. I clicked the "Debug" tab
  3. In the "Enable Debugers" section, I saw that the "(x) Enable the Visual Studio hosting process" checkbox was already checked.
  4. I tried un-checking the "( ) Enable the Visual Studio hosting process" option
  5. I saved these changes (Ctrl+S)
  6. I then checked the "(x) Enable the Visual Studio hosting process" checkbox once more
  7. I saved these changes (Ctrl+S)

My next re-build of the project was then successful.

Luckily, I was able to observe how the .vbproj file changed in my version control, and saw that it added the following line into it (which was not there before, despite the checkbox already being set initially):

<UseVSHostingProcess>true</UseVSHostingProcess>
Baxie answered 10/4, 2018 at 6:26 Comment(0)
P
0

None of the answers in this worked for me. I had to run Visual Studio as admin. Hope this helps someone in the future!

If you don't know how to run a program as admin on Windows, click this link.

Performance answered 5/12, 2018 at 12:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.