10

Bit of a strange one here guys.

We have a fairly complex (111 projects spread across asp.net, silverlight, WFC, Ria Services etc) solution, which builds correctly on my dev box (2010). If I fire up VS on our build machine, I can also build the solution correctly. However, when I queue a build, it almost makes it through, until it attempts to run SGen - at which point I get the old "Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information." chestnut.

I've googled to try to find a solution, but nothing appears to do the job - the error is occurring at complile time rather than runtime, and I've added the v2 activation key to Team build host's config file to no effect. There are no tests in the solution which might cause things to be loaded.

Any ideas? Anyone? Particularly confused that VS can build ok on the server, but team build fails.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
user452423
  • 101
  • 1
  • 3

1 Answers1

18

The following trick has worked for me (ref.)

Edit (or create if it does not exist) sgen.exe.config which should be located under:

  • C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\

or on a x64 OS:

  • C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\

Then add:

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0"/>
  </startup>
</configuration>

As far as I understand, adding the same snippet in the app.config of the project might no be sufficient as it's not read by the sgen tool :(

Yann Trevin
  • 3,823
  • 1
  • 30
  • 32
  • 1
    Note: The above snippet needs to be placed inside `` tags. – Darrell Mozingo May 27 '11 at 18:23
  • @Darrell. Updated accordingly. Thanks. – Yann Trevin Jul 13 '11 at 19:17
  • 2
    Also note that on an x64 system this should be C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\. There can be an x64 version of sgen.exe and that one doesn't work. – RandomEngy Jul 18 '11 at 03:32
  • 1
    Can anyone comment on whether this is a hack to workaround an issue, or is this the _correct_ workaround to a MS bug? – Richard Ev May 01 '12 at 12:52
  • 1
    Note... This changes to `C:\Program Files\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools` and `C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools` if you're using .Net 4.5! – PGallagher Jun 07 '13 at 08:23