ASPNETCOMPILER错误ASPCONFIG:无法加载文件或程序集“Microsoft.VisualBasic.Activities.Compiler”或其依赖项之一

时间:2010-06-16 17:22:51

标签: .net .net-4.0 teamcity aspnet-compiler

我刚刚将项目从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\work\8bbb8fc03bd91944\Dependencies\wnvxls.dll" to "Website\\Bin\wnvxls.dll".
[12:11:50]: Copying file from "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\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\work\8bbb8fc03bd91944\Website.metaproj]
[12:11:50]: Done Building Project "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\Website.metaproj" (Rebuild target(s)) -- FAILED.
[12:11:50]: Done Building Project "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\MyProject.sln" (Rebuild target(s)) -- FAILED.
[12:11:50]: Done Building Project "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\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\work\8bbb8fc03bd91944\MyProject.sln.teamcity.patch.tcprojx" (TeamCity_Generated_Build;TeamCity_Generated_NUnitTests target) (1) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\MyProject.sln" (Rebuild target) (2) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\Website.metaproj" (Rebuild target) (3) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\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\work\8bbb8fc03bd91944\MyProject.Other\MyProject.Other.csproj]
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\MyProject.sln.teamcity.patch.tcprojx" (TeamCity_Generated_Build;TeamCity_Generated_NUnitTests target) (1) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\MyProject.sln" (Rebuild target) (2) ->
[12:11:50]: "C:\Program Files\TeamCity\buildAgent\work\8bbb8fc03bd91944\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\work\8bbb8fc03bd91944\Website.metaproj]
[12:11:50]: 1 Warning(s)
[12:11:50]: 1 Error(s)
[12:11:50]: Time Elapsed 00:00:31.48

我尝试将.net框架引用程序集复制到C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.0,这样可以解决问题,但仍然没有运气。有什么想法吗?

9 个答案:

答案 0 :(得分:10)

对我而言,确实是x86 / x64不匹配。我通过MSBuild环境变量指定x64 MSBuild的路径来解决它:

Set the MSBuild environment variable

答案 1 :(得分:7)

我从VS构建.csproj_deploy时遇到了同样的错误。包括解决方案中的Web在内的所有其他项目都很好。在我的web bin文件夹中实际上有这个Microsoft.VisualBasic.Activities.Compiler dll。当我单击构建/清理解决方案时,除此之外,文件夹中的所有文件都被删除。我手动删除了这个文件并重新构建,它构建得很好。 这次,我甚至没有在bin文件夹中看到这个文件。

答案 2 :(得分:6)

此错误与引用旧版(v3或v3.5)系统程序集的解决方案中的类库有关。我的网站引用了这些类库,因此系统程序集与类库一起被复制到bin文件夹。也许3.5目录中的系统程序集具有与4.0目录不同的权限,当aspnet_compiler试图从bin目录加载它们时,它就会被禁止。

浏览完每个csproj文件并将<RequiredTargetFramework>值更新为4.0后,所有内容都按预期工作。

答案 3 :(得分:2)

看起来像x86 / x64不匹配 - 我强烈建议实际使用框架安装程序,而不是通过手动复制文件来攻击它

答案 4 :(得分:2)

我发现提交的非常简单的解决方案here为我解决了问题,即安装Windows SDK for .NET Framework 4(或Windows版本的等效文件)。

请注意,对于“智能感知和参考装配”所接受的答案的评论是解决此问题所需的SDK中唯一的功能。

答案 5 :(得分:2)

对我有用的简单解决方案是修改.vbproj文件的TargetFrameworkVersion行。只需将“v4.0”更改为“4.0”即可删除所有copmiler错误并修复我的智能感知问题(asp.net标记未被识别)。

答案 6 :(得分:2)

我们在切换托管环境(使用IIS的新Web服务器)时出现此错误。

修复是:

  • 更改应用程序池/高级设置,并将Enable 32 bit applications设置为true
  • 从已经属于框架的bin文件夹中删除所有程序集(例如我们在bin文件夹中有System.Data.dll,显然是为32b构建的 - 删除它修复了问题)

答案 7 :(得分:0)

我发现我对Microsoft.VisualBasic.Activities.Compiler&#39; DLL。一旦我删除了引用,所有事情都有效。

答案 8 :(得分:0)

如果要在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