Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy the .NET desktop program WINFORM or WPF

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how to deploy the .NET desktop program WINFORM or WPF. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

The current WIN7 operating system comes with. Net 3.5, the user base is relatively large, and the later version of WIN8,WIN10 with .NET is different. The default .NET of the WINDOWS SERVER operating system is not enabled, and the .NET components need to be enabled manually. Because desktop programs rarely run on server systems, SERVER systems are not considered.

When developing front-end desktop programs, many of the previous front-end programs will be developed with MFC or interface libraries based on MFC. The advantage is that they do not need to care about the operating system and can be run directly. There are also through DUILIB, SOUI and other DirectUI-based interface libraries for development, this is more flexible than MFC, the interface can be done more dazzling, others, such as using QT or WTL are also more common.

Relatively speaking, the easiest way to develop is to use C # to develop based on WPF or WINFORM, and the code is faster. But there is a problem with this kind of development, that is, the compatibility of .NET. If the installation package comes with a .NET, this can cause deployment to be cumbersome and sometimes fail.

Because now the XP operating system is rarely useful, if there is, it can only be installed with. Net 4.0 (XP supports up to. Net 4. 0, why not let users install. Net 3.5, because the 3.5 installation package is too large).

Having said so much, let's start to actually talk about the deployment method. Since the WINDOWS VISTA version has not been actually tested, consider testing this for yourself.

First, first consider whether your program should run on XP, if necessary, the installation package to check whether the user installed .NET during the installation process, if not, prompt the user to install .NET, or directly install the package with a .net 4.0 installation package to run automatically.

Second, if you do not want to be compatible with .NET, but only want to run in WIN7 or above, then develop WINFORM or WPF based on .NET 3.5. Sometimes the interface effect of a program developed in .NET 3.5 is different from that based on versions such as. Net 4.0 and needs to be tested.

Add the following code to the App.config file

Note that the startup node is placed in front of the inside of the configuration.

This configuration means that if you have both. NET3.5 and. NET4.0 in your operating system, use .NET 3.5 to start the program first, and if not, use .NET 4.0 to start the program. Of course, if there is no. Net 4.0 and. Net 4.5, then the program will be started with. Net 4.5.

If you do not add the above code, then you develop programs based on. Net 3.5 and will simply fail to run on WIN10.

Note: this configuration file will eventually be released with the EXE program, for example, if your EXE name is HAHA.EXE, then Config is like HAHA.EXE.CONFIG name. The above configuration must be included in this HAHA.EXE.CONFIG. By default, VS will automatically output the configuration without manual operation.

There are problems with the installation of .NET 3.5 for individual users, which will cause the program not to run properly. At this time, you can pay attention to this line and try to install .NET 4.0 for the user.

Fourth, make sure that your program runs properly for. Net 3.5,. Net 4.0,. Net 4.5. Finally, you can test the program separately in pure WIN7,WIN8,WIN10 without the need for additional installation of .NET.

Fifth, because of the particularity of .NET, the generated program had better be encrypted, otherwise it is easy to be cracked, for example, you can consider the open source. Net obfuscator ConfuserEx.

After the above operation is completed, if we only deploy desktop programs for WIN7 and above operating systems, then we do not need to come with .NET, nor do we need to install .NET, we can directly double-click to run.

On how to deploy the .NET desktop program WINFORM or WPF to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report