One-Click application moving from Windows Forms to

2019-04-08 19:23发布

问题:

I have a Windows Forms application that I recently re-wrote in WPF, and I need to release it to my end users. I'd like to be able to have the users go to the ClickOnce install point for the WPF application and have their Windows Forms application removed, so they don't have both on their machine.

What's the best way (read: easiest for users) of accomplishing this?

I have thought about creating an prerequisite command line to detect the old version and uninstall, but I would like to avoid having to write something like that where it only gets run once.

回答1:

I think you actually SHOULD be able to deploy the WPF version as a new version of the Windows Forms application.

What version of the .NET Framework do each of the applications target?

Is the assembly name on both projects the same, and is the installation URL the same? (For ClickOnce, it has nothing to do with the projectGUID.)



回答2:

I haven't tried it, but could you make your WPF app directly replace your WinForms app? If you publish to the same folder, copy the right GUID's from the old project to the new project, it might just install seamlessly.

That won't remove the old versions, but every update to a ClickOnce app leaves the old versions in place.

Alternatively, can you transform your existing WinForms project into a WPF project? Is it just a different set of assembly references? I've never written a WPF app, so forgive me if this is obviously wrong.



回答3:

Why not simply give the new WPF application the same <ProjectGuid>, <PublishUrl>, etc and a higher major version number?

ClickOnce won't even be aware you switched from WinForms to WPF technology.

Normal ClickOnce version update functionality will automatically replace the old code with the new the next time the application is updated (which can be set to happen automatically if desired).