2013-04-16 121 views
1

自从升级我们的解决方案以来,我一直在使用TFS 2012构建服务器生成.NET 4.5构建时遇到问题到.NET 4.5。我遇到了一些麻烦,说明TFS为什么会生成一个运行时异常。使用.NET 4.5构建运行时异常(无法从程序集'mscorlib加载类型'System.Runtime.CompilerServices.ExtensionAttribute')

  • 解决方案中的所有项目都声明.NET 4.5为目标 框架。
  • 解决方案可以在运行VS2012 Pro的本地开发人员机器上正确构建和运行。
  • 解决方案在Team Foundation Build Server 2012上正确构建。
  • 构建于构建服务器上的解决方案会引发下面的运行时异常。
  • 从VS2012生成并建立服务器都指C:\的Windows \ Microsoft.NET \组件\ GAC_32 \ mscorlib程序\ v4.0_4.0.0.0__b77a5c561934e089 \ mscorlib.dll中在运行时 (由两个应用日志和与跟踪确认procmon.exe)
  • C的版本:\ Windows \ Microsoft.NET \组件\ GAC_32 \ mscorlib程序\ v4.0_4.0.0.0__b77a5c561934e089 \ mscorlib.dll中被4.0.30319.18034
  • 浏览与程序Ildasm.exe表明C:\ Windows \ Microsoft.NET \程序集\ GAC_32 \ mscorlib \ v4.0_4.0.0.0__b77a5c561934e089 \ mscorlib.dll包含类型'System.Runtime.CompilerServices.ExtensionAttribute'。
  • 该应用程序是32位的。
  • 我不相信我们的构建过程使用ILMerge.exe(我们有单独的dll或每个项目)。

从构建服务器构建中遇到的运行时异常,表明无法找到已移动到mscorlib.dll中在4.5版本的预期类型“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 ...). 

当表面上他们动态链接到mscorlib.dll的.NET 4.5版本时,为什么TFS会生成抛出此运行时异常?

一些相关的SA的问题:

+0

http://stackoverflow.com/questions/13748055/could-not-load-type-system-runtime-compilerservices-extensionattribute-from-as –

+0

@SyedUmarAhmed观察到我已经链接到这个问题。您想要指出该主题中是否有一些内容? – ebpa

+0

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

回答

0

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

相关问题