Question

I am having some issues building a merged DLL to target .net4.0 on a windows 8 machine. I can successfully build individual .net4.0 dlls in VS2012 so I do not have this problem:

Targeting .NET 4.0 in VS 2012 on Windows 8

I have come across the following excellent blog post which discuss my issue:

http://www.mattwrock.com/post/2012/02/29/What-you-should-know-about-running-ILMerge-on-Net-45-Beta-assemblies-targeting-Net-40.aspx

and also:

Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib

which suggests I use the following syntax during the merge:

/targetplatform:"v4,C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"

Unfortunately in windows 8 I do not have this directory. I can think of the following possible solutions but would be interested to know if anyone has already solved this.

  1. Copy the .net 4.0 assemblies from a windows 7 machine into the above directory manually.
  2. Find the .net 4.0 assemblies being used by VS2012 and reference those.
  3. ??
Was it helpful?

Solution 2

Many thanks for the comments and feedback. A working (hacky) solution was to do the following:

  1. Create a new directory on windows 8, C:\Program Files\Reference Assemblies\Microsoft\Framework\v4.0.
  2. Go to a windows 7 machine, which does not have .net4.5 installed, and copy the contents of the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319
  3. Paste the files from step 2 into the folder created in step 1.

I was then able to correctly reference the .net4.0 assemblies in Windows 8 using the following:

/targetplatform:"v4,C:\Program Files\Reference Assemblies\Microsoft\Framework\v4.0"

Tested as working ok.

OTHER TIPS

I am also using Windows 8, and VS 2012 but have not come across that issue (and surely, a bunch of other people are fine as well). Very simply, it may just be that you have v3.5 or v4.5 installed and that means you need to install v4.0 framework (... again if you already tried).

I also found that the folder path you gave did not take me anywhere on my PC, but this path did;

C:\Program Files\Reference Assemblies\Microsoft\Framework\

Can you try that path on your PC and see if there is a v4.0 folder there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top