Old 5th October 2008, 09:52   #1
kporter20
Registered User
 
Join Date: Oct 2008
Posts: 18
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
kporter20 is offline   Reply With Quote
Old 5th October 2008, 12:00   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,531
This might work, I don't have .net 3.X so I can't test

code:

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}


IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th October 2008, 08:42   #3
kporter20
Registered User
 
Join Date: Oct 2008
Posts: 18
First test of this seemed to return v2.0... even if 3.0/3.5 is installed.
kporter20 is offline   Reply With Quote
Old 6th October 2008, 08:44   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,531
so the message box says Version=2.0 when you run it?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th October 2008, 14:04   #5
kporter20
Registered User
 
Join Date: Oct 2008
Posts: 18
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.
kporter20 is offline   Reply With Quote
Old 6th October 2008, 14:16   #6
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
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
Animaether is offline   Reply With Quote
Old 7th October 2008, 19:03   #7
kporter20
Registered User
 
Join Date: Oct 2008
Posts: 18
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.
kporter20 is offline   Reply With Quote
Old 7th October 2008, 19:09   #8
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
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
Animaether is offline   Reply With Quote
Old 7th October 2008, 19:47   #9
kporter20
Registered User
 
Join Date: Oct 2008
Posts: 18
OK. I'll wade through the parts I think I need and convert it to the NSIS language.

Thanks
kporter20 is offline   Reply With Quote
Old 7th October 2008, 20:30   #10
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
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.
Animaether is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump