I have an webapi application running .net4 that I am trying to get working on a server. The api works fine locally.
Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
What do I need to change to get this to work on my server?
Are you sure you were compiling against .NET 4 and not .NET 4.5? We moved ExtensionAttribute to mscorlib in .NET 4.5 (so we could put extension methods in mscorlib). I'd expect to see an error like that if you compiled something against .NET 4.5 and tried to run it on .NET 4.
EDIT: Actually, if you are using ILMerge, you need to use the path to the .NET 4.0 reference assemblies in the targetplatform switch, instead of the path to the implementation, as described in this blog post: http://www.mattwrock.com/post/2012/02/29/What-you-should-know-about-running-ILMerge-on-Net-45-Beta-assemblies-targeting-Net-40.aspx
Another possible solution (others with same exception) could be that your build server has not have the .net 4.0 reference assemblies, after installing .net 4.5 you'll need to copy them from your dev box.
These are typically somewhere like:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0
For more details see Marc's blog post
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With