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的問題:
http://stackoverflow.com/questions/13748055/could-not-load-type-system-runtime-compilerservices-extensionattribute-from-as –
@SyedUmarAhmed觀察到我已經鏈接到這個問題。您想要指出該主題中是否有一些內容? – ebpa
您是否在構建機器上安裝了Windows 8 SDK? Windows 8 SDK將安裝.NET 4.5參考程序集。您應該確保構建腳本引用.NET 4.5引用程序集,而不是直接引用.NET4.5二進制文件。 – Varun