1
votes

I have been having trouble producing a .NET 4.5 build using our TFS 2012 build server since upgrading our solution to .NET 4.5. I am having some trouble identifying why TFS builds throw a runtime exception.

  • All projects in the solution declare .NET 4.5 as the Target framework.
  • Solution builds and runs properly on local developer machines running VS2012 Pro.
  • Solution builds properly on Team Foundation Build Server 2012.
  • Solution built on build server throws the below run-time exception.
  • Builds from VS2012 and build server both refer to C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll at runtime (confirmed by both application logging and tracing with procmon.exe)
  • The version of C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll is 4.0.30319.18034
  • Browsing with ildasm.exe shows that C:\Windows\Microsoft.NET\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll does contain the type 'System.Runtime.CompilerServices.ExtensionAttribute'.
  • The application is 32-bit.
  • I don't believe our build process uses ILMerge.exe (we have separate dlls or each project).

The run-time exception encountered with the build from the build server showing that is unable to find the expected type 'ExtensionAttribute' that was moved into mscorlib.dll in version 4.5:

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 ...).

Why do TFS builds throw throw this runtime exception when ostensibly they are dynamically linking to the .NET 4.5 version of mscorlib.dll?

Some related SA questions:

1
@SyedUmarAhmed Observe that I already linked to that question. Was there some content in that thread that you wanted to point out?ebpa
Do you have Windows 8 SDK installed on the build machine? Windows 8 SDK will install .NET 4.5 reference assemblies. You should ensure that your build script is referencing .NET 4.5 reference assemblies instead of directly referencing .NET4.5 binaries.Varun
Actually it solved my problem , I have an application on .Net framework 4.0 but i installed 4.5 also.. after installing it never came again..Syed Umar Ahmed

1 Answers

0
votes

Do you have Windows 8 SDK installed on the build machine? Windows 8 SDK will install .NET 4.5 reference assemblies. You should ensure that your build script is referencing .NET 4.5 reference assemblies instead of directly referencing .NET4.5 binaries. You are likely directly referencing .NET 4.5 binaries which is incorrect.