MRefBuilder and .NET 4.0 Assemblies

Editor
Sep 28, 2009 at 8:51 PM
Edited Mar 1, 2010 at 5:41 PM

In case anyone needs to use MRefBuilder to parse .NET 4.0 assemblies, you need to create a config file for it that tells it to use the .NET 4.0 runtime (C:\Program Files\Sandcastle\ProductionTools\MRefBuilder.exe.config):

<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0.30128"/> <!-- 4.0 RC installed by VS2010 RC -->
    <supportedRuntime version="v4.0.21006"/> <!-- 4.0 Beta 2 installed by VS2010 Beta 2 -->
    <supportedRuntime version="v4.0.20506"/> <!-- 4.0 Beta 1 installed by VS2010 Beta 1 -->
    <supportedRuntime version="v2.0.50727"/> <!-- 2.0 RTM -->
  </startup>
</configuration>

Update the 4.0 version number as new releases are made.  Once created, MRefBuilder will parse assemblies built against any .NET version.  Thanks to Mike Tumy who originally passed this info on to me via e-mail.

Eric

 

Oct 3, 2009 at 2:54 PM

This does not really work for me. I still get the same error message:

-------------------------------

Generating reflection information...

[C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe]

GenerateRefInfo:

MrefBuilder (v2.4.10520.1)

Copyright c Microsoft 2006

Unknown target platform version '4.0'.

C:\Users\Laci\egyetem\lego\Help\Working\GenerateRefInfo.proj(35,5): error MSB6006: "MRefBuilder.exe" exited with code 1.

Last step completed in 00:00:00.4040

-------------------------------

Editor
Oct 3, 2009 at 8:37 PM
Edited Oct 3, 2009 at 8:38 PM

That is a separate issue.  The current release of SHFB doesn't correctly handle .NET 4.0 when creating the configuration file used for the build which is different from the exe.config file.  You can work around it temporarily be selecting "3.5" for the framework version project property.  All it controls is the framework version that it tells MRefBuilder to use (1.0 or 2.0).  The 2.0 value works for 2.0 and up.

Eric

 

Oct 3, 2009 at 11:04 PM

If I build my VS project for .net3.5 it works well if I select "3.5" in SHFB.

But when I build my VS project for .net4.0, either I choose "3.5" or "4.0.20506" in SHFB I get the same message: Unknown target platform version '4.0'

Editor
Oct 4, 2009 at 1:04 AM

If you're using the solution or project as a documentation source, it's finding the framework version in there and overriding the one from the SHFB project.  The workaround for that is to add the assembly and the XML comments file as documentation sources for the time being.  I'll probably release a new version of SHFB in a few weeks that fixes these issues.

Eric

 

Oct 4, 2009 at 9:12 AM
Edited Oct 4, 2009 at 12:44 PM

So another workaround is to build the VS project as .net4.0 then change the VS project framework property to .net3.5 save it, but do not rebuild, and finally add this VS project to Sandcastle GUI.

but this does not work always

Nov 25, 2009 at 4:07 PM

Thank you for the tip about creating MRefBuilder.exe.config - I was able to create one for VS2010 Beta using the example given and Sandcastle was able to run.

May 24, 2010 at 8:41 AM
With the release of VS2010 you need to add a line similar to this as well: <supportedRuntime version="v4.0.30319"/> <!-- 4.0 final installed by VS2010 final -->