MRefBuilder and .NET 4.0 Assemblies

Sep 28, 2009 at 9:51 PM
Edited Mar 1, 2010 at 6: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"?>
    <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 -->

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.



Oct 3, 2009 at 3:54 PM

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


Generating reflection information...



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


Oct 3, 2009 at 9:37 PM
Edited Oct 3, 2009 at 9: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.



Oct 4, 2009 at 12:04 AM

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'

Oct 4, 2009 at 2: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.



Oct 4, 2009 at 10:12 AM
Edited Oct 4, 2009 at 1: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 5: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 9: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 -->