ASPNETCOMPILER 错误 ASPCONFIG:无法加载文件或程序集“Microsoft.VisualBasic.Activities.Compiler”或其依赖项之一
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3055633/
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
ASPNETCOMPILER error ASPCONFIG: Could not load file or assembly 'Microsoft.VisualBasic.Activities.Compiler' or one of its dependencies
提问by Jim Geurts
I just upgraded my project to Asp.Net 4, from 3.5. When the build kicks off from TeamCity, I get the following error:
我刚刚将我的项目从 3.5 升级到 Asp.Net 4。当构建从 TeamCity 开始时,我收到以下错误:
[Project "Website.metaproj" (Rebuild target(s)):] C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /Website -p Website\ -u -f PrecompiledWeb\Website\
[12:11:50]: [Project "Website.metaproj" (Rebuild target(s)):] ASPNETCOMPILER error ASPCONFIG: Could not load file or assembly 'Microsoft.VisualBasic.Activities.Compiler' or one of its dependencies. An attempt was made to load a program with an incorrect format.
[12:11:50]: MSBuild output:
[12:11:50]: Copying file from "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\Dependencies\wnvxls.dll" to "Website\Bin\wnvxls.dll".
[12:11:50]: Copying file from "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\Dependencies\wnvxls.xml" to "Website\Bin\wnvxls.xml".
[12:11:50]: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /Website -p Website\ -u -f PrecompiledWeb\Website\
[12:11:50]: ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'Microsoft.VisualBasic.Activities.Compiler' or one of its dependencies. An attempt was made to load a program with an incorrect format. [C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\Website.metaproj]
[12:11:50]: Done Building Project "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\Website.metaproj" (Rebuild target(s)) -- FAILED.
[12:11:50]: Done Building Project "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\MyProject.sln" (Rebuild target(s)) -- FAILED.
[12:11:50]: Done Building Project "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\MyProject.sln.teamcity.patch.tcprojx" (TeamCity_Generated_Build;TeamCity_Generated_NUnitTests target(s)) -- FAILED.
[12:11:50]: Build FAILED.
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\MyProject.sln.teamcity.patch.tcprojx" (TeamCity_Generated_Build;TeamCity_Generated_NUnitTests target) (1) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\MyProject.sln" (Rebuild target) (2) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\Website.metaproj" (Rebuild target) (3) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\MyProject.Other\MyProject.Other.csproj" (Rebuild target) (5) ->
[12:11:50]: (CoreCompile target) ->
[12:11:50]: Helpers\ProgramHelper.cs(40,21): warning CS0168: The variable 'ex' is declared but never used [C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\MyProject.Other\MyProject.Other.csproj]
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\MyProject.sln.teamcity.patch.tcprojx" (TeamCity_Generated_Build;TeamCity_Generated_NUnitTests target) (1) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\MyProject.sln" (Rebuild target) (2) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\Website.metaproj" (Rebuild target) (3) ->
[12:11:50]: (Rebuild target) ->
[12:11:50]: ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 'Microsoft.VisualBasic.Activities.Compiler' or one of its dependencies. An attempt was made to load a program with an incorrect format. [C:\Program Files\TeamCity\buildAgent\workbbb8fc03bd91944\Website.metaproj]
[12:11:50]: 1 Warning(s)
[12:11:50]: 1 Error(s)
[12:11:50]: Time Elapsed 00:00:31.48
I tried copying the .net framework reference assemblies to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 thinking that would fix things, but still no luck. Any thoughts?
我尝试将 .net 框架参考程序集复制到 C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 认为可以解决问题,但仍然没有运气。有什么想法吗?
采纳答案by Jim Geurts
This error had to do with class libraries in the solution referencing older (v3 or v3.5) system assemblies. Those class libraries were referenced by my website, so the system assemblies got copied to the bin folder along with the class libraries. Maybe the system assemblies in the 3.5 directory have different permissions than the 4.0 directory and when the aspnet_compiler tried to load them from the bin directory, it barfed.
此错误与解决方案中引用旧(v3 或 v3.5)系统程序集的类库有关。我的网站引用了这些类库,因此系统程序集与类库一起复制到 bin 文件夹中。也许 3.5 目录中的系统程序集与 4.0 目录具有不同的权限,当 aspnet_compiler 尝试从 bin 目录加载它们时,它会发出警报。
After going through each csproj file and updating <RequiredTargetFramework>values to 4.0, everything is working as expected.
在浏览每个 csproj 文件并将<RequiredTargetFramework>值更新为 后4.0,一切都按预期工作。
回答by Sjoerd
For me it was indeed an x86/x64 mismatch. I solved it by specifying the path to the x64 MSBuild through the MSBuild environment variable:
对我来说,这确实是 x86/x64 不匹配。我通过通过 MSBuild 环境变量指定 x64 MSBuild 的路径来解决它:


回答by sri
I got the same error building the .csproj_deployfrom VS. All other projects including the web in the solution built fine. There was actually this Microsoft.VisualBasic.Activities.Compilerdll in my web bin folder. When I clicked build/clean solution, all the files in the folder got deleted except this. I manually deleted this file and built again and it built fine.
This time, I do not even see this file in the bin folder.
我在.csproj_deploy从 VS构建时遇到了同样的错误。解决方案中的所有其他项目(包括 Web)都构建得很好。Microsoft.VisualBasic.Activities.Compiler我的 web bin 文件夹中实际上有这个dll。当我点击构建/清理解决方案时,文件夹中的所有文件都被删除了。我手动删除了这个文件并重新构建,它构建得很好。这一次,我什至在 bin 文件夹中都没有看到这个文件。
回答by Holf
I found the very simple accepted solution presented herefixed the issue for me, this being installing the Windows SDK for .NET Framework 4(or the equivalent for your Windows version).
我发现这里提供的非常简单的公认解决方案为我解决了这个问题,这是为 .NET Framework 4(或您的 Windows 版本的等效版本)安装Windows SDK。
Note the comment on the accepted answer that says "Intellisense and Reference Assemblies" are the only features from the SDK needed to fix this issue.
请注意对已接受答案的评论说“智能感知和参考程序集”是解决此问题所需的 SDK 的唯一功能。
回答by Jason
The simple solution that worked for me was to modify the TargetFrameworkVersion line of the .vbproj file. Simply changing "v4.0" to "4.0" removed all of the copmiler errors and fixed my intellisense issues (asp.net tags were not being recognized).
对我有用的简单解决方案是修改 .vbproj 文件的 TargetFrameworkVersion 行。只需将“v4.0”更改为“4.0”即可消除所有编译器错误并修复了我的智能感知问题(无法识别 asp.net 标签)。
回答by veljkoz
We had this error when switching our hosting environments (to the new web server with IIS).
在切换我们的托管环境(到带有 IIS 的新 Web 服务器)时,我们遇到了这个错误。
The fix was:
修复是:
- Either change the Application pool / Advanced settings, and set
Enable 32 bit applicationstotrue, or - Delete all assemblies from the bin folder that already belong to the framework (e.g. we had
System.Data.dllin our bin folder, which was obviously built for 32b - deleting it fixed the issue)
- 更改应用程序池/高级设置,并设置
Enable 32 bit applications为true,或 - 从已经属于框架的 bin 文件夹中删除所有程序集(例如
System.Data.dll,我们的 bin 文件夹中有,这显然是为 32b 构建的 - 删除它可以解决问题)
回答by Rowland Shaw
Looks like an x86/x64 mismatch - I'd strongly recommend actually using the framework installer, than hacking it by copying the files by hand
看起来像 x86/x64 不匹配 - 我强烈建议实际使用框架安装程序,而不是通过手动复制文件来破解它
回答by OJisBad
I found that I had an unnecessary reference to the 'Microsoft.VisualBasic.Activities.Compiler' dll. Once I removed the reference, all things worked.
我发现我对“Microsoft.VisualBasic.Activities.Compiler”dll 有一个不必要的引用。一旦我删除了参考,一切都奏效了。
回答by Michael Armitage
If you are building a web project in x64 in Visual Studio and running on IIS Express you must enable the following setting:
如果要在 Visual Studio 中以 x64 格式构建 Web 项目并在 IIS Express 上运行,则必须启用以下设置:
Tools --> Options --> Projects & Solutions --> Web Projects --> Use the 64 bit version of IIS Express for web sites and projects
Tools --> Options --> Projects & Solutions --> Web Projects --> Use the 64 bit version of IIS Express for web sites and projects

