vb.net “GenerateResource”任务 CLR2 运行时错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28708997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 18:50:00  来源:igfitidea点击:

"GenerateResource" task CLR2 runtime error

vb.netvisual-studio-2013msbuild.net-3.5runtime-error

提问by soulblazer

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

我的应用程序不断收到此错误(顺便说一下,我使用的是 VS 2013、VB.NET 和 Windows 8.1):

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.

无法运行“GenerateResource”任务,因为 MSBuild 无法创建或连接到具有运行时“CLR2”和体系结构“x86”的任务主机。请确保 (1) 请求的运行时和/或体系结构在计算机上可用,以及 (2) 所需的可执行文件“C:\Program Files (x86)\MSBuild\12.0\bin\MSBuildTaskHost.exe”存在并且可以运行。

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.

该应用程序适用于 .NET 3.5(3.5 及更低版本让我出现此错误)。我尝试再次运行该应用程序。有时,它有效;有时,错误又回来了。

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.

我已经尝试在 Google 上寻找答案,结果他们给我的答案是:“您构建的用户名太长”(他们说 20 个或更多字符会导致错误),但事实并非如此。我的用户名只有 5 个字符。无论如何,我认为我的构建用户名的长度与它没有任何关系;这没有道理。

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

有谁知道 3.5 及更低版本有什么问题?谢谢你。

回答by Stefan Steinegger

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:

要解决它,请转到您的 csproj 文件并在默认属性组下添加以下行:

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

Found here.

这里找到。

回答by Ruben Rivero

Clean and rebuild solution worked for me.

清洁和重建解决方案对我有用。

回答by Nikhil Agrawal

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.

单击开始>>右键单击计算机>>属性>>高级系统设置>>单击环境变量按钮打开对话框,然后在系统变量部分下,单击新建...按钮,输入变量名称= DISABLEOUTOFPROCTASKHOST,然后输入变量value = 1,然后单击“确定”。

More here

更多在这里

回答by Zaehos

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

这其中的所有答案都不适合我。我必须以管理员身份运行 Visual Studio。希望这对未来的人有所帮助!

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

如果您不知道如何在 Windows 上以管理员身份运行程序,请单击此链接

回答by Ing. Silvestre Govea Rodriguez

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

顺便说一下,我使用的是 VS 2013、VB.NET 和 Windows 10 64 位

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

只需更改 XML 属性,服务:.NET Framework 4.6 而不是 .Net Framework 2.0(默认)

and working fine for me.

对我来说工作正常。

回答by Salvador Nieto

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

DisableOutOfProcTaskHost=true

回答by Andrew Stephens

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.

我在尝试构建包含在C:\Program Files\. Visual Studio 提示我以提升的权限重新启动(就像在“安全”位置打开解决方案时那样),但是构建失败并显示 OP 的错误消息。

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

将解决方案复制到“普通”文件夹(例如 C:\Temp)为我解决了这个问题。

回答by Gurce

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

我最近尝试在 VS2013 中打开一个旧的 VS2010 vb 项目,但遇到了这个问题。我是这样解决的:

  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-checkingthe "( ) Enable the Visual Studio hosting process" option
  5. I saved these changes (Ctrl+S)
  6. I then checkedthe "(x) Enable the Visual Studio hosting process" checkbox once more
  7. I saved these changes (Ctrl+S)
  1. 我去了vb项目的属性页面
  2. 我点击了“调试”选项卡
  3. 在“启用调试器”部分,我看到“ (x) 启用 Visual Studio 托管进程”复选框已被选中。
  4. 我尝试取消选中()启用 Visual Studio 托管进程”选项
  5. 我保存了这些更改 (Ctrl+S)
  6. 然后我再次选中了“ (x) 启用 Visual Studio 托管进程”复选框
  7. 我保存了这些更改 (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):

幸运的是,我能够观察到 .vbproj 文件在我的版本控制中是如何变化的,并看到它添加了以下行(尽管最初已经设置了复选框,但之前没有):

<UseVSHostingProcess>true</UseVSHostingProcess>