I have an app built with .net 3.5. If a user runs it without having .net 3.5 installed I want to have control of what they see perhaps provide a message that they can understand (with a link to .net 3.5) versus unhandled exception stack traces. But if they don't actually have .net 3.5 how can my app control anything?
views:
698answers:
4Are you assuming that at least SOME version of .NET is installed?
You could write a small loader to be compatible with all versions to do the check.
Or if .NET is not installed, found a simple batch program (though this could easily be done in C++ if you prefer).
@ECHO OFF
SET FileName=%windir%\Microsoft.NET\Framework\v1.1.4322
IF EXIST %FileName% GOTO Skip
ECHO.You currently do not have the Microsoft® .NET Framework 1.1 installed.
ECHO.This is required by the setup program for MyApplication.
ECHO.
ECHO.The Microsoft® .NET Framework 1.1 will now be installed on you system.
ECHO.After completion setup will continue to install MyApplication on your system.
ECHO.
Pause
SET FileName=
Start /WAIT .\dotnetfx.exe
Start .\Setup.exe
ECHO ON
Exit
Tongue Tiedkip
SET FileName=
Start .\Setup.exe
ECHO ON
Exit
This might also help.
You could instead consider using an installer that requires 3.5 is installed. That would prevent the app from getting to the user in the first place if they can't run it.
You need an non .NET exe that checks for the .NET runtimes. It could be written in anything that you know exists in the target PC. For example, if targeting Windows 2000 or above, you know the VB6 runtime is present, so your installer could always start a VB6 splash application that checks for the runtimes before starting your .NET exe. A better way would be to write a C++ app that didn't rely on any runtime other than the Windows APIs.
Better yet, you could use an installer technology, such as Wix or a Visual Stuido setup project, that checks during installation that all the prerequisites for you software, such as a particular .NET framework runtime exist. If not, it will install them, or at least tell the user where to get them and what to do next