views:

283

answers:

3

My application requires the .NET Framework version 3.5. I recently ran into a customer that had the .NET Framework installed but turned off on Windows Vista (also applies to Windows 7).

In this case, my installer (InstallShield 2009) does not prompt the user to install the Framework (because it is already installed) and when my application runs it crashes immediately. I tried another .NET application and it also crashes immediately.

Is there any way to detect this situation and handle it more gracefully? Just detecting this during install is not ideal since the .NET Framework can be turned off at any time. Ideally, the application would be able to check and display a friendly message to the user telling them they need to turn on the .NET Framework.

EDIT: "Turning off" the .NET Framework in Windows Vista or Windows 7 is not the same as uninstalling it. The Framework can be simply turned back on without reinstalling: http://windows.microsoft.com/en-US/windows-vista/Turn-Windows-features-on-or-off

+6  A: 

When I turned off the feature, the value in the registry that indicated the framework is installed got deleted. You could check that value.

Take a look at: HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5

KevinH
Thanks, so I can check that registry key but I would have to do it from and un-managed launcher, right?
John Myczek
Yeah, unfortunately there won't be a way around that since the feature can be turned off and on at will.
KevinH
+3  A: 

Looks like you're going to write a non-managed launcher for your app. Roll up your sleeves and have a nice C++ dive :)

Fábio Batista
+1  A: 

Woot, I think this URL might have your answer:

http://blogs.msdn.com/astebner/archive/2008/04/04/8358995.aspx

See "How to install the .NET Framework 3.0 OS component in a deployment scenario". It describes using ocsetup to trigger Windows to turn the feature on, as far as I can tell. Best of luck.

Also, I'm curious if ClickOnce installers are intelligent to know if the feature is turned off (I imagine they would be). But since you're using InstallShield you probably want a more fully-featured installer than clickonce ;o)

Jon
The solution I mentioned is for .NET 3 but I bet you can use the same approach for 3.5.
Jon