title: Can application built with .NET 4.5 run on .NET 4.0?
body: <p>My project is targeting to .NET 4.5. It doesn't use any new 4.5 methods, so it actually works fine on the machine with only .NET 4.0 installed.</p>
  
  <p>This is all good until I added some extension methods and reflection. Then when I ran this .NET 4.5 program on the 4.0 machine, it failed with "System.TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly mscorlib". The famous ExtensionAttribute program that has been documented well <a href="http://www.mattwrock.com/post/2012/02/29/What-you-should-know-about-running-ILMerge-on-Net-45-Beta-assemblies-targeting-Net-40.aspx" rel="noreferrer">here</a>.</p>
  
  <p>Another quick way to test this is to add the following line. Then the program will throw the exception when running on .NET 4.0 only.</p>
  
  <pre><code>Console.WriteLine(typeof(System.Runtime.CompilerServices.ExtensionAttribute).Assembly.FullName);
  </code></pre>
  
  <p>I'm wondering if there is a way to work around it. For example, the ILMerge (when using the correct /targetplatform option as documented in the link) actually changes the ExtensionAttribute from mscorlib to System.Core if the project is target to .NET 4.0 (with 4.5 installed). But it doesn't seem to work on the project targeted to .NET 4.5.</p>
  
  <p>I know this is a long shot. But just want to see if anyone has other ideas since it was so close.</p>
  
  <p>Thanks.</p>