简体   繁体   中英

C#.NET 3.5 Windows application need to run in .NET FRAMEWORK not installed machine also

I developed a windows application in .net framework 3.5 and it is working fine in all the machines if I use setup exe. Because, in the setup I added the prerequest .net framework 3.5. So the setup will check, the local PC has .net framework 3.5 or not. If not, the prerequest will work at first then after the remaining setup will be working. In this way, the created windows application exe working fine.

But my client's requriement is, they are not ready to install setup in each and evey machine and they simply telling that they will copy paste bin folder contents only. Inside of that bin folder we can use any number of exe's or dlls etc what ever we want. But inside of that bin folder we can use only one SHORT CUT and that shortcut name should be "UserClickHere".

The user always click on the "UserClickHere" shortcut only. That shortcut need to open Setup.exe at first time and from next time onwards our windows application need to open. (Note:- At first time, after installation of setup.exe, our windows application exe should be open automatically).

This is my requirement, please can anybody give me example codes.

Thanks in advance.

Here is your solution:

  1. You have to make an additional application the shortcut will point at (preferably unmanaged)
  2. This application first checks if the .NET Framework 3.5 SP1 is installed:

    int version = (int)Registry.LocalMachine.GetValue(@"Software\Microsoft\NET Framework Setup\NDP\v3.5", "SP", (int)0);

  3. If version less than 1, you should download and install the framework:

    WebClient client = new WebClient(); client.DownloadFile("http://download.microsoft.com/download/0/6/1/061f001c-8752-4600-a198-53214c69b51f/dotnetfx35setup.exe", "dotnetfx35sp1.exe");

    Process.Start("dotnetfx35sp1.exe", "/lang:enu /qb /norestart").WaitForExit();

  4. Now you can run your WPF application:

    Process.Start("MyApp.exe");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM