Archive: Detect if .NET 3.5 is installed


Detect if .NET 3.5 is installed
Hi, first post here.

I have an application I have developed which requires .NET 3.5 to be installed.

How do I detect if this runtime is installed?

I have managed this for applications using .NET 2.0 but how I detect if .NET 3.5 is installed.

Thanks


This might work, I don't have .net 3.X so I can't test


GetDllVersion "$sysdir\mscoree.dll" $R0 $R1
IntOp $R0 $R0 / 0x00010000
${If} $R0 >= 2

;http://blogs.msdn.com/junfeng/archiv...07/436755.aspx
!define RUNTIME_INFO_UPGRADE_VERSION 0x01
!define RUNTIME_INFO_DONT_RETURN_DIRECTORY 0x10
!define RUNTIME_INFO_DONT_SHOW_ERROR_DIALOG 0x40
System::Call "mscoree::GetRequestedRuntimeInfo(i0,i0,i0,i0,i ${RUNTIME_INFO_UPGRADE_VERSION}|${RUNTIME_INFO_DONT_RETURN_DIRECTORY}|${RUNTIME_INFO_DONT_SHOW_ERROR_DIALOG},\
i0,i0,*i,w .r0, i ${NSIS_MAX_STRLEN}, *i)i.r1"

${If} $1 == 0
MessageBox mb_ok Version=$0
${Else}
MessageBox mb_ok error=$1
${EndIf}
${EndIf}

First test of this seemed to return v2.0... even if 3.0/3.5 is installed.


so the message box says Version=2.0 when you run it?


Yes. It corresponds to the version of the CLR that the .NET Framework is using I think. As .NET 3.5 still uses the 2.0 CLR this is what is getting reported.


blatant copy/paste from a previous post;

check the following code sample from Aaron Stebner (*tips hat*) for detecting the various .NET framework versions and service packs:
http://astebner.sts.winisp.net/Tools/detectFX.cpp.txt


I have tried to use some of this inside an NSIS installer file to detect if just .NET 3.5 is installed but none of it seems to compile properly.


hi kporter.. that's because that code is in C++, rather than in NSIS language. Basically, though, it's reading out of registry values (ReadRegStr etc.) to determine if the product was installed or not


OK. I'll wade through the parts I think I need and convert it to the NSIS language.

Thanks


I'm making a header file for this, but ran into a potential problem with VersionCompare.. *groan*

Also I'm currently installing Framework 3.5.. make sure that check actually works.. and of course it asks me to close pretty much every application I have open. yeesh.