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.

1 Answer 1

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 :(

5
  • 1
    Note: The above snippet needs to be placed inside <configuration></configuration> tags. Commented May 27, 2011 at 18:23
  • @Darrell. Updated accordingly. Thanks. Commented Jul 13, 2011 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
    Commented Jul 18, 2011 at 3: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
    Commented May 1, 2012 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
    Commented Jun 7, 2013 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.