Login Register






Targeting a higer version of .NET filter_list
Author
Message
Targeting a higer version of .NET #1
ugh I wrote this out and accidentally hit refresh !@#

Most people like to target version 2.0 of the .NET framework, because it's on pretty much every PC at this point. However I like to use the newest version, because they generally include nice features I like to use. The problem is almost no one keeps up to date on their .NET versions unless they happen to install something else that needs the version you want to target. I solve this problem with what I call a "loader". Instead of distributing your binary you distribute the loader. I write mine in C++ so this will be geared towards that, but you can use what ever language you want that will execute.


Create a Win32 Console Application in VS.

Add a version checking class
Add a class to handle the installation of your program

In the .NET version checking class it's pretty simple to figure how what version is installed. Below are the registry checks you need to look for.

"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4";
"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v3.5";
"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v3";

As you can probably guess the key that ends is v4 is present if version 4.0 is installed and so on down the line. Now if it's not found simply download the version you want to target and install it silently. You do this by passing /q /norestart to the .NET installer.


Assuming everything went fine in the .NET installation have your other installer class download your binary and execute it.

In the main function of your Win32 Console Application make sure to put the following code at the top so it hides the box during all of this.

HWND hWnd = GetConsoleWindow();
ShowWindow(hWnd, SW_HIDE );

The .NET installer is kind of big around 50mb or so, but that really shouldn't be a problem, because all of this is running in the background.

Hope this helps someone,
puma

Reply

RE: Targeting a higer version of .NET #2
You should be fine with compiling in .NET Framework 3.5 though, no need to go any lower than that, because most computers should have it by now. If they don't you make then download it, and if you want to use .NET Framework 4, personally I say go for it, just get the end user to install it, it's for their own benefit too.
ArkPhaze
"Object oriented way to get rich? Inheritance"
Getting Started: C/C++ | Common Mistakes
[ Assembly / C++ / .NET / Haskell / J Programmer ]

Reply

RE: Targeting a higer version of .NET #3
(11-27-2011, 01:48 AM)Infinity Wrote: You should be fine with compiling in .NET Framework 3.5 though, no need to go any lower than that, because most computers should have it by now. If they don't you make then download it, and if you want to use .NET Framework 4, personally I say go for it, just get the end user to install it, it's for their own benefit too.

That's the point of the installer. It's downloads it for them and installs it silently in the background. Obviously, if your installing something they want to install then they'll install it for themselves.

Reply