在 Web 部署项目期间,ASP.NET 编译器失败并出现 XmlSerializers 错误

发布于 2024-10-27 06:33:39 字数 801 浏览 2 评论 0原文

我们在构建过程中使用 Visual Studio 2010 Web 部署项目来编译 Web 应用程序网站。我们的构建代理上未安装 Visual Studio 2010。在构建过程中,我们收到一个错误(见下文),该错误与自动生成的 Foo.XmlSerializers.dll 相关,该错误是使用比当前加载的运行时更新的运行时构建的,并且无法由 aspnet_compiler.exe 加载。

我们的项目文件以 .NET Framework v3.5 为目标。

这是错误(针对长行重新格式化):

"C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj" (Build target) (1) ->
  (AspNetCompiler target) ->
    ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 
    'Foo.FrontEnd.Site.XmlSerializers' or one of its dependencies. 
    This assembly is built by a runtime newer than the currently loaded 
    runtime and cannot be loaded.   
[C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj]

We're using Visual Studio 2010 Web deployment projects to compile web-application websites during our build. Visual Studio 2010 is not installed on our build-agents. We get an error (see below) during the build relating to the automatically-generated Foo.XmlSerializers.dll being built with a runtime newer than the currently loaded runtime and cannot be loaded by aspnet_compiler.exe.

We're targeting .NET Framework v3.5 in our project files.

Here's the error (reformatted for long lines):

"C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj" (Build target) (1) ->
  (AspNetCompiler target) ->
    ASPNETCOMPILER : error ASPCONFIG: Could not load file or assembly 
    'Foo.FrontEnd.Site.XmlSerializers' or one of its dependencies. 
    This assembly is built by a runtime newer than the currently loaded 
    runtime and cannot be loaded.   
[C:\BuildAgent\work\3836706d661b8a05\project\src\Foo.FrontEnd.WdpSite\
Foo.FrontEnd.WdpSite.wdproj]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Spring初心 2024-11-03 06:33:39

我遇到了类似的问题,具有相同的错误消息,经过多次挫折后找到了解决方案(希望能够为此提供一些想法)。

这里我们有一个带有 Windows SDK 7.1(以及使用 Vs 2008 时的 6.1)的构建服务器,用于构建面向 .NET 3.5 的 VS 2010 项目。然后使用 aspnet_compiler 预编译 Web 项目(从 v2 开始,按照 http: //msdn.microsoft.com/en-us/library/ms229863.aspx#findingthe Correctversion)。在预编译过程中,我收到了与您相同的错误消息,涉及一个项目(不是 Web,只是普通库),其中包含对 Web 服务的 Web 引用。看起来 Windows SDK 7.1 没有正确设置使用 .NET 3.5 工具的注册表路径(而 Visual Studio 则可以)。这导致 Web 引用使用 .NET 4 的目标运行时进行编译(使用反射器进行验证),因此 aspnet_compiler v2 适合。我比较了构建服务器和本地 Visual Studio 安装的注册表设置,结果显示 SDK 7.1 的 .NET 3.5 配置不好,因此我使用以下内容更正了构建服务器。我的猜测是,Web 引用 xml(在非 Web 项目中)正在使用 .NET 4 的 sgen 进行预编译,作为未使用正确的 .NET 3.5 sgen 的后备措施。应用注册表更改后,一切都很好(我的构建服务器注册表中不存在以下内容,因此我创建了它)。

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx35Tools-x86]
"ComponentName"="Windows SDK .NET Framework 3.5 Multi-targeting Utilities"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"

作为补充说明,我还使用 WindowsSdkVer 将 7.1 设置为默认 SDK。

I was having a similar issue, with the same error message, and after lots of frustration found the solution (which hopefully will give some ideas for this).

Here we have a build server with Windows SDK 7.1 (and 6.1 from when using Vs 2008) building VS 2010 projects targeting .NET 3.5. The web projects are then pre-compiled with aspnet_compiler (from v2 as per http://msdn.microsoft.com/en-us/library/ms229863.aspx#findingthecorrectversion). During pre-compilation I received the same error message as yourself for a project (not web, just normal library) with a web reference to a web-service. It looks like Windows SDK 7.1 doesn't set up the registry paths correctly for using .NET 3.5 tools (while Visual Studio does). This caused the web references to be compiled with a target runtime of .NET 4 (validated using reflector) so aspnet_compiler v2 had a fit. I compared the registry settings of the build server and my local visual studio install which showed the .NET 3.5 configuration for SDK 7.1 was not good, so I corrected the build server with the below. My guess is the web reference xml (in the non-web project) was being precompiled with sgen for .NET 4 as a fall back for not using the correct .NET 3.5 sgen. Once the registry change was applied everything was fine (the below didn't exist in my build server registry so I created it).

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx35Tools-x86]
"ComponentName"="Windows SDK .NET Framework 3.5 Multi-targeting Utilities"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.1\\bin\\"
"ProductVersion"="7.1.7600.0.30514"

Just as an aditional note I also used WindowsSdkVer to set 7.1 as the default SDK.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文