1

自从将我们的解决方案升级到 .NET 4.5 后,我一直无法使用我们的 TFS 2012 构建服务器生成 .NET 4.5 构建。我无法确定为什么 TFS 构建会引发运行时异常。

  • 解决方案中的所有项目都将 .NET 4.5 声明为目标框架。
  • 解决方案在运行 VS2012 Pro 的本地开发人员机器上正确构建和运行。
  • 解决方案在 Team Foundation Build Server 2012 上正确构建。
  • 基于构建服务器构建的解决方案会引发以下运行时异常。
  • 从 VS2012 构建和构建服务器都在运行时引用 C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll(通过应用程序日志记录和使用 procmon.exe 进行跟踪确认)
  • C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll 的版本是 4.0.30319.18034
  • 使用 ildasm.exe 浏览显示 C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll 确实包含类型“System.Runtime.CompilerServices.ExtensionAttribute”。
  • 该应用程序是 32 位的。
  • 我不相信我们的构建过程使用 ILMerge.exe(我们有单独的 dll 或每个项目)。

来自构建服务器的构建遇到的运行时异常显示无法找到在 4.5 版中移入 mscorlib.dll 的预期类型“ExtensionAttribute”:

System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType ...). System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType ...).

为什么 TFS 构建在表面上动态链接到 .NET 4.5 版本的 mscorlib.dll 时会抛出此运行时异常?

一些相关的 SA 问题:

4

1 回答 1

0

您是否在构建机器上安装了 Windows 8 SDK?Windows 8 SDK 将安装 .NET 4.5 参考程序集。您应该确保您的构建脚本引用 .NET 4.5 引用程序集,而不是直接引用 .NET4.5 二进制文件。您可能直接引用了不正确的 .NET 4.5 二进制文件。

于 2013-05-03T01:44:54.760 回答