Eric Yin
Eric Yin

Reputation: 8973

Put dotNet Install Package Locally with WPF Program

I have a WPF program, a standalone one, copy from "Release" directory. So its a green software without installation.

BUT it requires .net 4.0 installed. So I have "dotNetFx40_Full_x86_x64.exe" on the distribution USB disk.

Problem is, when my program run on XP (without .net 4.0), it will say it needs .net 4.0 and ask user if they want to go online to download it even I have a local copy on the disk.

My question is, is there anyway let the program install the .net locally without go online to download.

Upvotes: 1

Views: 449

Answers (3)

Ming Slogar
Ming Slogar

Reputation: 2357

I had exactly the same problem.

Eventually I bit the bullet and created a native C++ bootstrapper (no .NET required to execute) which checked if .NET was installed, and if not, installed it. The bootstrapper then started up the .NET program.

Upvotes: 1

Muhamed Krlić
Muhamed Krlić

Reputation: 1472

Standard way of doing this is by creating an installation and setup package which will include your application as well as the .NET framework.

The user will run your setup program and install what is required.

EDIT :

If you do not want to use an Installer you could use Ngen.

The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Ngen.exe creates native images, which are files containing compiled processor-specific machine code, and installs them into the native image cache on the local computer. The runtime can use native images from the cache instead using the just-in-time (JIT) compiler to compile the original assembly.

Unfortunately, you still need the libraries from the .net framework in order to run your program. There's no feature that I know of with the Microsoft .Net framework SDK that allows you to compile all the required files into a single executable

EDIT 2 :

After a bit of searching, this is also worth checking out. It's called Spoon Studio here are It's features. Looks like this is what you were looking for.

Execute .NET, Java and AIR-based applications with no separate installation steps or runtime versioning conflicts. The Spoon virtual machine supports all versions of the .NET Framework and Java, including .NET 4.0, 4.2, and 4.5.

Deliver virtualized applications in standalone EXEs, on intranets with Spoon Server, or on the web with Spoon.net.

Standalone executable generation packages all virtual machine and application payload content as a single EXE file that can be deployed using any standard file delivery mechanism or existing desktop management infrastructure.

Upvotes: 3

Manuel Schweigert
Manuel Schweigert

Reputation: 4974

If you do not want to use an installer, you will need to make a launcher instead of running your application from the start.

If you can guarantee .net 2.0 on your system, you could create a 2.0 Winforms project in your solution, check the framework-version like this, if it is not 4 start the installer synchronously, when it finishes running, check the framework version again and finally start your application.

You could start your application without having to have another .exe in there. You would use Assembly.Load to load your project (which you should compile to a class library then) and call your application startup function.

You will definitely not be able to do this in only one file, though. You need either a native application or .net 2.0 application as launcher.

Upvotes: 2

Related Questions