I had to make my bootstrapper (dotNetInstaller) detect .NET 4.  At the time,
the best advice I could find was to use the registry keys mentioned in that
SO post.  This has been working reliably for some time.

If you're using WiX you can use the WixNetFxExtension and add PropertyRefs
for the specific versions and SPs you require...

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension";
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension";>

    <!-- ... -->

    <PropertyRef Id="NETFRAMEWORK35" />    <PropertyRef
Id="NETFRAMEWORK40FULL" />

    <!-- ... -->




On Thu, Jun 16, 2011 at 9:26 PM, Ian Thomas <[email protected]> wrote:

>  Wal –that’s good, but iirc tuples require 4.0
>
>
>  ------------------------------
>
> Ian Thomas
> Victoria Park, Western Australia
>   ------------------------------
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Wallace Turner
> *Sent:* Thursday, June 16, 2011 6:47 PM
>
> *To:* ozDotNet
> *Subject:* Re: Installed CLR versions
>
>
>
> Hi Ian, I need to test the client has the correct framework installed. I
> use something like this: (turn heads Tuple-haters)
>
>
>  public static
>
> bool HasDotNetFrameworkMatching(decimal targetVersion, inttargetServicePack
> )
>
>     {
>
>         foreach (Tuple<decimal, int> version in GetNETFrameworks())
>
>         {
>
>             decimal framework = version.First;
>
>             decimal servicePack = version.Second;
>
>             if (framework == targetVersion && servicePack == 
> targetServicePack)
>
>                 return true;
>
>         }
>
>
>
>         return false;
>
>     }
>
>
> If you want the rest of the code then email me direct.
>
>
> On 16/06/2011 5:17 PM, Ian Thomas wrote:
>
> Thanks for suggestions.
>
> It's probably as simple to check the framework folders installed on the
> machine (and to test that each has some valid files and is not empty), as to
> try to interpret the registry subkeys. I can't find a good explanation (eg,
> the CDF subkey - what's that?).
>
> The stackoverflow article is a bit cross-purpose (and I had investigated
> that way anyway).
>
> The system.environment.version() of course gives the CLR version under
> which the test assembly was compiled (and will fail, perhaps ? - need to
> test this - if the running machine doesn’t have CLR 4 installed).
>
> I guess the safe way is to check via the Windows Installer and my
> installation, but I haven’t checked recently whether a custom action is
> available to test for installed CLR or .NET Frameworks up to 4.0 (I did see
> some post about the NSIS installer being way out of date with its
> detection).
>
> clrver.exe is very nice - it gives the PID, assembly name, and CLR version
> for each currently running assembly on the machine. But it’s not a
> redistributable.
>
> Interestingly, explorer.exe (Windows Explorer shell) runs using CLR
> v4.0.30319 on my test machine.
>
> ________________________________
>
>
>
> Ian Thomas
>
> Victoria Park, Western Australia
>
>
>
>
>
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]<[email protected]>]
> On Behalf Of DotNet Dude
> Sent: Thursday, June 16, 2011 3:13 PM
> To: ozDotNet
> Subject: Re: Installed CLR versions
>
>
>
> Maybe check the registry: HKLM\Software\Microsoft\Net Framework Setup\NDP
>
>
>
>
>
> On Thu, Jun 16, 2011 at 4:54 PM, Ian Thomas 
> <[email protected]><[email protected]>wrote:
>
> > Apart from the utility clrver.exe (and the latest, v4.0.30319.1 is needed
> to
>
> > report both 2.0 and 4.0), how can I determined the installed versions of
> the
>
> > CLR on a machine?
>
> >
>
> > I can't discover a .NET function to report this.
>
> > ________________________________
>
> > Ian Thomas
>
> > Victoria Park, Western Australia
>
> >
>
> >
>
>
>

Reply via email to