3

I have an application 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 and 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 application control anything?

4 Answers 4

4

Are 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.

Sign up to request clarification or add additional context in comments.

2 Comments

Well, you could just write the loader as a small C++ app that checks the registry for .NET... However I would discourage this because it may inhibit compatibility in the future. Someone ever wrote a batch program for it.
Well. The way I phrased the question... I need to work on that.
2

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

2 Comments

I just started using Wix just because I wanted an installer and the project types came with SharpDevelop. I didn't realize it would make this issue irrelevant.
Oh. Is there something special I need to do to the Wix project to make it check for .net 3.5?
2

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.

Comments

1

You need an non .NET EXE file 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 Visual Basic 6.0 runtime is present, so your installer could always start a Visual Basic 6.0 splash application that checks for the runtimes before starting your .NET EXE file. A better way would be to write a C++ application that didn't rely on any runtime other than the Windows APIs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.