Pitfalls/gotchas of ClickOnce/smart-client deployment in .NET [closed]

非 Y 不嫁゛ 提交于 2019-12-02 15:33:48
Darrel Miller

Here are a few that I am aware of.

  1. Can't put an icon on the desktop. You can now.

  2. I can't install for all users.

  3. I need to jump through hoops to move the deployment to a different server. It is not a problem if you are developing internally, and the users can see the server that you are publishing to or if you are deploying to the public web, but it is not great if you need to roll out to multiple customer sites independently.

  4. Since .NET 3.5 SP1 you do not need to sign the deployment manifest anymore which makes it much easier to move deployments to new servers.

  5. I can't install assemblies in the GAC. You can get around this by creating regular install packages that are pre-requisites of the ClickOnce application.

Nicholas Piasecki
  • When updates are deployed, the built-in dialog will make it appear as if the entire application is being re-downloaded. In fact, only the changed DLLs are being downloaded, and the progress bar displayed is misleading/wrong. Don't waste time trying to figure out why all the assemblies are being re-deployed only to discover that they actually aren't. Not that I did that or anything.
  • When the certificate that you used to sign the original deployment manifest expires and you are issued a new one, you're in for a world of hurt (clients will all need to uninstall and reinstall). Details are at the horse's mouth.
codeConcussion

Most issues have been addressed but several people mentioned not being able to create a desktop shortcut. In fact, you can create a desktop shortcut with Visual Studio 2008 SP1.

Also, if you aren't using the latest version of Visual Studio, you can always write code to create a shortcut to the installed start menu shortcut.

We had an app we were going to deploy as a ClickOnce app. We needed the user to be able to modify some settings in the installation (such as the deployment path - IT wants to serve the files from their network share, not known at build time). When you change any of the files in your deployment, you need to re-calculate all of the hashes, and re-sign everything. So, if this solution is internal, you may not have problems passing around a signing cert, but if this is for clients, you will need to architect a fancy solution to bypass this issue.

I have heard rumblings from somewhere within the bowels of the internets that a future version of ClickOnce will remove some of this headache.

You can't silently uninstall ClickOnce deployed applications. Also I think it's impossible to add parameters to the startup shortcut.

MagicKat

One of the pitfalls with ClickOnce is the fact that you can't install to the GAC. This is a problem if you want to install multiple applications that share DLL files. Each application will require a local copy of the DLL files. Also, multiple user installs are out. See the list comparing Window Installer to ClickOnce.

aSkywalker

In case someone refers to this in a search, we have found many customers concerned with the lack of security 'distributing' their application. The application must be available in a public location - without any authentication - for it to be able to check for updates. The only exception is if you have Windows NT authentication. I think Securing ClickOnce Applications explains what I mean.

Desktop icons are fairly trivial to do via code, and as mentioned, with 3.5 SP1, baked in - so that is no longer an issue.

There is still an unfixed bug with the xmlSerializer - it doesn't get deployed properly in some cases. An easy workaround is to manually add this file to the deployment. PITA, but it is easy enough... It can be shocking when your deployment suddenly fails though...

Tom Kidd

There are a whole lot of things you can't do with ClickOnce applications, like install a shortcut to the user's desktop or have any sayso in where the application gets installed. For some people these are dealbreakers.

Also it's been a while since I used it, but there's a special way you can use to figure out and display the ClickOnce version/build number, which is separate from the application's version/build number. You have to do a try/catch and if the ClickOnce version/build number throws an exception then the application is not running as a ClickOnce-deployed application (that is, it's running as a regularly compiled application or from Visual Studio).

For an application which is simple (that is, not Microsoft Word, but rather a quick-and-dirty application to do something) and needs a lot of regular deployment, ClickOnce is great. But you rather quickly hit the wall of "oh, this can't be done by ClickOnce, please choose MSI or something else).

Davy Landman

You'll have less system access than your normal .NET application.

That's because you'll get a lower trust level. More about that in .NET Framework Developer's Guide: ClickOnce Deployment and Security.

My biggest problem with that was that it's not possible to encrypt sections of your configuration file with the machine key, because you don't have the access to that key (when you think about it it makes sense to protect that key).

Jamie Ide

I didn't know that SP1 allowed you to create the desktop icon.
Here's how we have been doing it (now known as "the hard way"):

try
{
    string company = string.Empty;
    string product = string.Empty;
    if (Attribute.IsDefined(asm, typeof(AssemblyCompanyAttribute)))
    {
        AssemblyCompanyAttribute asCompany = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyCompanyAttribute));
        company = asCompany.Company;
    }
    if (Attribute.IsDefined(asm, typeof(AssemblyProductAttribute)))
    {
        AssemblyProductAttribute asProduct = (AssemblyProductAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyProductAttribute));
        product = asProduct.Product;
    }
    if (!string.IsNullOrEmpty(company) && !string.IsNullOrEmpty(product))
    {
        string desktopPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
            product + ".appref-ms");
        string shortcutPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs),
            Path.Combine(company, product + ".appref-ms"));
        File.Copy(shortcutPath, desktopPath, true);
    }
}
catch 
{
    // Shortcut could not be created
}
Nik

You can't install if the client is behind a proxy that requires authentication.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!