.NET ClickOnce not installing prerequisite files?

2019-01-24 10:15发布

问题:

I have a .NET project that uses Crystal Reports. The application is distributed using ClickOnce. Things work great if the user has Crystal installed on their computer. However, not all of the end users have Crystal Reports installed on their computers. These users are receiving the following error...

"Unable to install or run the application. The application requires that assembly CrystalDecisions.ReportAppServer.XmlSerialize Version 10.5.3700.0 be installed in the Global Assembly Cache (GAC) first."

Is there a way to force ClickOnce installs to ensure that a prerequisite is installed?

回答1:

No. There is a lot of confusion over ClickOnce and prerequisites.

ClickOnce does nothing with prereqs. Nothing. ClickOnce copies files from a server to a client's machine and keeps those files in sync when the server files are updated - that's it. It can't put things in the GAC, register dlls, install msi files, etc.

Where the confusion comes in is when you deploy with Visual Studio. VS does several things for you when you publish that really have nothing to do with ClickOnce. For one, it creates a nice html page for you with some links to your deployment. Also, it lets you pick from several prereqs and will create a bootstrapper exe for you. I'm assuming you did this for the Crystal Reports install. The bootstrapper is just a simple way to manage multiple prereqs. Rather than telling your user to install X, then Y, then Z before installing your app, the bootstrapper makes those three installs "seamless" so they appear as if they are one big install. It can also skip prereq installs if the user already has it.

If you pay attention on your html page that VS generates, you can see two links. One to your .application file (the ClickOnce deployment) and one to the bootstrapper exe. You are pretty much at the mercy of the user and must rely on them to read the page and run the bootstrapper if they need to. The one exception to that is the .Net Framework since the html page can check for that through the UserAgent string.

If they don't run the bootstrapper they'll get errors much like the one you're asking about.

One possible solution is to write code to check if it's installed. It could check the registry or the "Program Files" folder; whatever you need to do to make sure it's installed. Then exit gracefully and inform the user if they don't have it. That will work as long as you do the check before you try to load and use the Crystal assemblies.

Good luck! Please respond if you come up with a better solution.



回答2:

In the Prerequistes , Select Crystsal Report for .Net Framework (NOT Crystal Report for Visual Studio ) and publish .