开发者

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

开发者 https://www.devze.com 2023-03-13 00:18 出处:网络
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 wil

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");

0

精彩评论

暂无评论...
验证码 换一张
取 消