Use ClickOnce to publish Windows applications

Foreword

Because I need to work, under the guidance of a very, very good teacher, entry of C #, thanked the teachers again.

I often encounter the usual business is to send data under the various departments, and let each department and then reported, this process often encounter incorrect data format, data error and many other issues. So I thought of writing a data reporting system, to standardize their data. But because knowledge is limited, temporary and other web MVC can not write a program, and therefore made a B / S version of WINFORM application, but do not want every update to the client send each of them to write code or set up your own server automatically update (because I am more lazy, the use of Microsoft's ClickOnce, feel very convenient, so I can not learn to write their own update this part, so after re-learn it). Now create a simple DEMO, I hope we can exchange learning together. Paper, some conceptual thing is referenced.

ClickOnce Profile

ClickOnce deployment allows you to publish to a Web server or network file share to simplify installation of Windows-based applications. Visual Studio provides full support for publishing and updating applications through ClickOnce deployment. ClickOnce deployment using Visual Basic, Visual C # and Visual J # projects created, but not for projects created using Visual C ++.

The benefits of using ClickOnce

Use ClickOnce to publish Windows applications allows users to easily update the application, can play a B / S, the updated program when a user does not have to re-install every update. Publishers just need to program the new version into the server, users can program to update the software when you start the software or exit the software (see a more detailed illustration of the publishing process).

Of course, to make the installation process more visual, more added during the installation and the installer should create their own.

Graphic publishing process

 First, the IIS configured, as shown below:

Next, select the item you want to publish, right-click and choose "Properties", then select "Publish" tab, as shown below:

 

 

 The first time you use the ClickOnce feature, we recommend using the "Publishing Wizard", "Browse" and select the directory when IIS is just configured, as shown below:

 

 Next: Note here that, in order to obtain the URL must use an administrator account to run IIS VS, otherwise it will prompt you to re-run as administrator. After the administrator running VS, just choose the configuration of IIS Web site, as shown below:

 

 

 

 

 

 Next, the program according to your needs, choose whether to run offline, I chose not allowed, the difference here is that if allowed, they will be an assembly once all be downloaded from the website to run locally, not through the website later run, this may appear, you have to update to 5.0 on the server, but they are still using the version 2.0. So I set only through the online use. As shown below:

 

 After clicking Finish, if nothing else, the easiest layout is complete, it will jump directly to the configured IIS Web page, as shown below:

 

 Click "Run", the program automatically downloaded and executed, as shown below:

 

 Click program will enter into operation, as shown below:

 

 Next, we tried to change my program's content, then publish once, to see the effect, the "hello world" was changed to "hello my friends!", And change the font color to orange, and then proceed to publish the interface program click "publish Now", the version number will be updated automatically by the change became 1.0.0.1 1.0.0.2, 1.0.0.1 refers to a previous version of the program after the release, 1.0.0.2 refers back to a program after the release of the next version number, as follows:

 

After the release, VS will automatically enter the new site, as shown below:

 

 We can see, the current release is version 1.0.0.1, click to run the program, the following picture:

 

 More than just the basic functions to automatically update via Microsoft ClickOnce to us. Next, I put the question to use the process also summarize:

1. program release, click on the run there may be, there is no run button (I figure there are the "Run" button, inconsistent here and win 10 win 7 interface, we encountered the case may try this method), the error Tip interface as follows:

 

 

 At this point you need to add the following to the registry there, you can solve this problem:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\Policy]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\Policy\Extensions]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\Policy\Extensions\NamedPermissionSets]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\Policy\Extensions\NamedPermissionSets\Internet]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\Policy\Extensions\NamedPermissionSets\Internet\MediaPermission]
"Xml"="<IPermission class=\"System.Security.Permissions.MediaPermission, WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\" version=\"1\" Audio=\"SafeAudio\" Video=\"SafeVideo\" Image=\"SafeImage\"/>"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\Policy\Extensions\NamedPermissionSets\Internet\WebBrowserPermission]
"Xml"="<IPermission class=\"System.Security.Permissions.WebBrowserPermission, WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\" version=\"1\" Level=\"Safe\"/>"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\Policy\Extensions\NamedPermissionSets\LocalIntranet]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\Policy\Extensions\NamedPermissionSets\LocalIntranet\MediaPermission]
"Xml"="<IPermission class=\"System.Security.Permissions.MediaPermission, WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\" version=\"1\" Audio=\"SafeAudio\" Video=\"SafeVideo\" Image=\"SafeImage\"/>"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\Policy\Extensions\NamedPermissionSets\LocalIntranet\WebBrowserPermission]
"Xml"="<IPermission class=\"System.Security.Permissions.WebBrowserPermission, WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\" version=\"1\" Level=\"Safe\"/>"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\TrustManager]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Security\TrustManager\PromptingLevel]
"MyComputer"="Enabled"
"LocalIntranet"="Enabled"
"Internet"="Enabled"
"TrustedSites"="Enabled"
"UntrustedSites"="Disabled"

 2. If your assembly has a plug-in or reference documents, to [add] in the application file, as shown below:

 

 

 

Required in the above document released this interface status changed to "include"

 

Required for replication in the above this interface files to the output directory to "Copy always", so that we can ensure that your DLL or some reference files can be distributed with your program out, or can be released although successful, but the program can not normal operation.

 

 

 

 

That is all I currently use some of the ideas, CliceOnce functionality than what I said to be more powerful, I just use some basic functions, it is possible there are many mistakes in the above, also please a lot of criticism, Thank you.

 

 

 

 

Guess you like

Origin www.cnblogs.com/nanqinling/p/11871536.html