Install Clickonce Programmatically Click

You can use ClickOnce deployment to install Office Add-ins for Office 2007 and Office 2010. It is very similar to deploying a desktop application, but not identical. With all types of ClickOnce deployments, you may include resources that you need to access programmatically. Files with a file extension of.xml,.mdf, and.mdb are assumed to be data and are deployed by default to the ApplicationDeployment.CurrentDeployment.DataDirectory, but non-data files will be found in the folder with the deployed assemblies.With a non-VSTO application, you can programmatically find the location of the deployment by either accessing System.Windows.Forms.Application.StartupPath or by checking the Location of the executing assembly.

With a VSTO application, the location of the executing assembly does not match the location of the deployment files.The dll for a VSTO add-in is copied from the deployment directory into a separate location, and it is loaded by the host application from there. I would guess that this happens whenever you run the host application (such as Outlook), and this is why the Office add-in can be uninstalled, reinstalled, updated, etc., without impacting the host application. The changes don’t take effect until the host application is closed and reopened.

So when you retrieve the executing assembly’s location, it points to the dll in the run location, and you can’t use that to track down the deployment files.So how do you find the location of the deployment? You have to examine the CodeBase property of the executing assembly. This comes across as a URI, so you have to retrieve the LocalPath from the URI. It also includes the file name of the main assembly, so you have to retrieve just the directory name specifically.Here’s the code in VB: 'Get the assembly informationDim assemblyInfo As System.Reflection. Assembly = System.Reflection. Assembly.GetExecutingAssembly'Location is where the assembly is run fromDim assemblyLocation As String = assemblyInfo.Location'CodeBase is the location of the ClickOnce deployment filesDim uriCodeBase As Uri = New Uri(assemblyInfo.CodeBase)Dim ClickOnceLocation As String = Path.GetDirectoryName(uriCodeBase.LocalPath.ToString)Here’s the code in C#: //Get the assembly informationSystem.Reflection. Assembly assemblyInfo = System.Reflection.

Programmatically

Assembly.GetExecutingAssembly;//Location is where the assembly is run fromstring assemblyLocation = assemblyInfo.Location;//CodeBase is the location of the ClickOnce deployment filesUri uriCodeBase = new Uri(assemblyInfo.CodeBase);string ClickOnceLocation = Path.GetDirectoryName(uriCodeBase.LocalPath.ToString);When you compare these values for a non-VSTO ClickOnce application, the directories are the same. When you are hosting a ClickOnce deployment on a webserver, you need have certain MIME types defined so the server knows how to handle the files. You can host a ClickOnce deployment on any server regardless of the operating system. So you can host a ClickOnce deployment on an Apache server just as easily as a server running Microsoft Windows Server. You just need to set up the right MIME types.When you install the.NET Framework, it registers the MIME types automatically. This is why you don’t have to set up MIME types if you install IIS on your desktop machine and test your deployments by deploying to localhost.

Carrying that forward, if you have the.NET Framework installed on your server, the MIME types should already be registered.This is generally one of the first things to check when you’re having problems downloading the deployment. There are some cool new features in.NET 4.0 and VS2010 for ClickOnce deployment. I’m going to summarize the new features here and provide some links to the details.The ClickOnce engine has been updated and strengthened, and the team that supports the runtime says that the errors that seem to have no solution, such as 'dfsvc.exe has stopped working', should be fixed. They have also added enhanced logging and the option to set the location (and name) of the ClickOnce log file — no more searching through your Temp folder! What’s cool about these changes is that they apply if you install.NET 4.0 on the computer, regardless of the version your application targets. So if you have a Windows Forms application that targets.NET 2.0 and you are having problems installing it, you can install.NET 4.0 on the computer and turn on the verbose logging. This has already been useful to me, so I will blog about it next.They have fixed “the certificate problem” in all cases.

The problem is discussed in detail. The basic problem was that when you changed the certificate used to sign the ClickOnce deployment, the customers would have to uninstall and reinstall the application. They fixed this in.NET 3.5 SP-1 if you used automatic updates, but not for programmatic updates, and not for VSTO projects. Now they have fixed it in all cases when targeting the.NET 4.0 Framework.With VS2010, you can configure your application to target multiple versions of the.NET Framework. Of course, this doesn’t mean it will run on multiple versions – you will have to verify that yourself.

To use this feature, you have to manually edit the manifest files and app.config file and re-sign the manifests. For details, click.For XBAP applications (browser-hosted WPF applications), these can now elevate to Full Trust just like any other ClickOnce application.

For more info, check out.For VSTO projects, you can now with one ClickOnce installation. Like the, it’s all for one and one for all.

Where Do Clickonce Apps Install

All of them are installed together, and if you uninstall through Programs, it uninstalls all of them.For VSTO projects, you also now have the ability to do some post-deployment actions. For example, you can create registry keys, modify a config file, or.Another interesting change for VSTO projects is if you are targeting the.NET 4.0 Framework, you no longer have to include the Primary Interop Assemblies as a prerequisite. The type information for the PIAs that you use in your add-in is embedded into the solution assembly and used at runtime instead of the PIAs.And last, but not least — in.NET 3.5 SP-1, they quietly introduced the ability to create your own custom UI for your ClickOnce deployment, while still using the ClickOnce engine to install and update your application. They have improved this feature for.NET 4.0; check out the walkthrough example.I think there’s something useful in the new features for everyone. If there are other features you would like to see – other than “install for all users”, which is a complete paradigm shift – please leave a comment. I will summarize the requests and pass them on to the ClickOnce team at Microsoft.Tags:Posted in,.

People frequently ask about the future of ClickOnce deployment. I hear and read things like “Microsoft hasn’t updated their ClickOnce blog since 2006.” “They never change anything in ClickOnce.” “You never hear anything about ClickOnce deployment updates.” “Are they going to keep supporting it?” “Why doesn’t Microsoft use ClickOnce themselves?”The answers to those questions are: 1. It’s not sexy so nobody talks about it. Yes they do.NET 3.5 included ClickOnce deployment for VSTO applications, which is awesome. And SP-1 included optional signing and hashing, file associations, and other fun stuff. You do if you know where to listen.

They use it for many of their apps used internally. I don’t think they can use it for. Can you imagine what the prerequisite list would look like?is sexy. The release of Silverlight 4 was even noted on one of the Apple News sites. How does “I created this really cool component that you can embed in a WPF application and it cleans your computer screen and tidies up your desk” compare with “I figured out how to install this really cool component on your computer.” See what I mean?Deployment is like delivery.

You don’t ever think about how your books get from that cool page on the web to your in two minutes (or, if you’re a traditionalist, to your front porch in two days), but aren’t you excited when they show up?Even though Microsoft doesn’t go on Oprah to discuss their feelings about ClickOnce deployment, I have discovered over the past few months that they really do care about it.Saurabh Bhatia, the ClickOnce expert at Microsoft, has been helping me over the past year to respond to some of the more difficult questions in the forums. When I attended the MVP Summit in February, I met with Saurabh and some of the other people who work in and around ClickOnce.

The 1-hour meeting stretched into 3-1/2 hours as we discussed feedback and information I had collected from the MSDN Forums, StackOverflow, blog articles, and from individuals who e-mailed me or talked to me after my presentations. I passed on complaints, common problems, and most frequently requested new features. They really wanted to know, and were glad to get the information.In return, they provided me with a look at what’s coming in.NET 4.0 (that’s the next blog post). Since I’ve returned, they have followed up with answers to my questions. (They were sending me e-mails with answers before I’d even left Washington!) Saurabh and one of his cohorts, Jason Salameh, continue to provide resources to help me support the ClickOnce Deployment community, and Saurabh set up regular meetings just to touch bases and help me with any difficult issues or questions that come up that I can’t answer. I think of it as a “Stump Saurabh!” session, but so far I’ve only managed to stump him once (proxy authentication).

I learn something new with every conversation.Also coming soon is an update of the Patterns and Practices Smart Client Software Factory and the ClickOnce documentation for it. (I know that because they asked me to do the update to the docs.

I was so flattered!)It’s safe to say that Microsoft will continue to support and enhance ClickOnce deployment. My next blog post will be a summary of the new features available in.NET 4.0. If there are features you want, post a comment and I’ll pass it along. If you have questions about problems you’re having with ClickOnce deployment, please post a question in the I’ll see you there.Tags:Posted in,. In ClickOnce Deployment, it is a common belief that you can not pass arguments to an application unless:. The application is deployed to a web server, and. The application is online-only.If you are interested in passing query parameters to an online-only application deployed to a web server, check out the.

About offline applications, or applications deployed via a file share, that page says this:However, this is no longer the case. I suspect it was changed when they added the ability to do file associations in.NET 3.5 SP-1. It turns out that you can now pass parameters to:. an offline ClickOnce application,. a ClickOnce application deployed to a file share, and even to. an offline ClickOnce application deployed to a file share.And of course you can pass parameters to an online-only application using query parameters, but we already knew that (see article referenced above).Here’s how you call the application and pass the arguments. //Get the ActivationArguments from the SetupInformation property of the domain.string activationData =AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;Here are three different ways to pass and receive arguments:.

Pass a file path and name as a URI. This mimics what happens when you set up a file association and double-click on a file with that extension. The argument will start with “file:”. Pass a query string with key-value pairs in it.

This is the same way you pass and parse query strings for an online-only application. The argument will start with a question mark. Pass one value or a list of comma-delimited values.Locate the shortcut for the application.The first thing you need to do is locate the shortcut in the start menu for the application you want to run — this is made up of the Publisher Name and Product Name. Here is how to find the location of the application’s shortcut. Process.Start(shortcutPath, argsToPass);The argument string that you pass can not have spaces or double-quotes in it. If you pass a b c, you will only get a on the receiving side. If you pass “a”,”b”,”c”, you will get a.

If you need to pass arguments with spaces, pass your arguments as a query string. How to create the argument string to be passed, and how to parse it on the receiving side.Case 1: Sending file path and name.

This mimics what happens when you use the ClickOnce properties to set up a file association, and the user double-clicks on an associated file.Build the argument string. If you are using a SQLServer Compact Edition database, you will need to deploy the software for it. You can deploy it as a prerequisite, but this requires the customer to install one more thing without clicking Cancel. He must also have administrative privileges.Additionally, version control is more difficult with ClickOnce deployment, because prerequisites are not handled by the incremental updates, and you can never get all of your customers to reinstall a prerequisite. At least one of them will be out of town, and when they come back, they’ll have too much e-mail to deal with and won’t take the time to follow your instructions to update their application.A better idea is to deploy the assemblies required locally.

This video explains all.In the interest of copy and paste and making your life easier, here are the 7 dll’s you need to locate and add to your project. You should be able to find them in C:Program FilesMicrosoft SQL Server Compact Editionv3.5 (or v3.0). If you are using 3.0, substitute “30” for “35” in the names of these dll’s.

sqlceca35.dll. sqlcecompact35.dll. Mac os x download free. sqlceer35EN.dl. sqlceme35.dll. sqlceoledb35.dll. sqlceqp35.dll.

sqlcese35.dllSet the Build Action to “Content”, and “Copy to Output Directory” to “copy always” on these entries in Solution Explorer. On the reference to the System.Data.SqlServerCe.dll in your project, set “Copy Local” to “true”.In other news about SQLCE databases (or any database, for that matter), if you are deploying one with ClickOnce deployment as data, did you know if you open the database it changes the timestamp, and deploys a new version next time you deploy an update? On the client side, it then copies the previous version to the ApplicationDatapre folder, and puts the new one to the ApplicationData folder. If you’re not handling this in your code, it looks like the user has lost his data. This kind of thing tends to annoy customers, which is always a bad thing that can lead to a loss of cash flow, if you know what I mean.For a easier way to handle updates and let your database change only when you intend it to, you might want to check out my blog entry titled I think the title is self-explanatory.Tags:,Posted in,.

In many cases, when the certificate you use to sign your ClickOnce deployment expires, your customers have to uninstall and reinstall the application. This is the problem discussed in my.Part of that article discusses the use of a program called RenewCert to extend your signing certificate, and tells you why you might want to do that.

The following video shows you how.The basic command looks like this:RenewCert oldpfxfile newpfxfile CN=newName password-to-old-pfx-fileLet’s say I have a certificate called NightbirdPFX.pfx that has expired. If I want to create a new version with the same public/private key pair, I would use this command:RenewCert NightbirdPFX.pfx NightbirdPFX5Yrs.pfx CN=”Nightbird 5 Yrs” MYpassw0rdNow I can replace the old certificate with the new and publish an update, and the users will be able to pick up the update without having to uninstall and reinstall the application.As noted in the GoldMail above, if you have a vendor certificate, it does change it to a test certificate. So if you still want to have a trusted deployment, you have to purchase a new certificate.The compiled version of RenewCert that I used to extend my vendor certificate can be downloaded This requires the C runtime libraries from Visual Studio 2005 in order to run, so I have included those in the zip file as well.I’d like to thank Cliff Stanford for taking the C code from MSDN and enhancing it so it works for both test certificates and vendor certificates.

If you’re interested, the code and compiled binary can be found.If you want to read the original article in MSDN and/or see Microsoft’s code, you can find it.Edit 7/7/2011 Move zip file to Azure blob storageTags:,Posted in,. One of the questions I see in the is how to move a ClickOnce deployment to a different location. You might want to move your deployment because your company is setting up a new webserver, or because you change hosting companies for your deployment.You can’t just change the URL because it’s part of the security built in to ClickOnce. It checks the update location for the installed application against the URL for the update, and if they don’t match, it won’t install the new version. This keeps someone from hijacking your deployment and substituting their own files.This video will show you how to move your deployment to a different URL.This download contains the source code (VS2008, C#) for the three versions of the application used in the video. If you are a VB developer and can’t figure out how to translate the code to VB, please post a comment and I’ll post a VB version of the code.(edit) I couldn’t see how this could work with an Office Solution (VSTO), so I did some looking around., so it looks like your customers have to uninstall and reinstall if you have to move a VSTO deployment. Dang.Tags:Posted in,.

I gave a talk in Mountain View at the South Bay.Net User Group meeting on August 5th. This was a general talk about ClickOnce Deployment and how to use it. Almost everyone in the room was a Windows Forms or WPF developer, which seems rarer and rarer these days as people migrate to web applications. There were a lot of questions, and a lot of good discussion about things that people would like changed in ClickOnce deployment.The most frequently requested feature in that meeting and in the MSDN ClickOnce Forum is to install a ClickOnce application for all users rather than a specific user.This is difficult because the files are stored in the user’s profile, where the user has read/write privileges.

Page

One of the design goals of ClickOnce is to provide a deployment technique that allows customers to install applications without elevated privileges. Installing an application for all users requires privileges.Another design goal was to protect the client machine from problems caused by software installations. Do you remember “dll hell”?

This was the problem that happened when another application came along and replaced a dll that you were dependent on, and caused problems for your application, or vice versa.In a ClickOnce deployment, it is possible to include most of the dll’s locally with the deployment, rather than installing them in the GAC or the windows system directory. (This is excluding, of course, the.NET Framework and other prerequisite applications such as SQLServer Express.) You can even deploy the SQL Compact Edition dll’s or DirectX dll’s. This allows you to maintain strict version control on the dll’s that you include in your deployment. Microsoft would have to figure out a way to handle this if the application were deployed for all users; if they weren’t careful, you could easily end up in dll hell again.On the other hand, if they just chose to put the files under the All Users profile, once again you have the permissions problem that Microsoft sought to handle with ClickOnce deployment, because the user can’t write to those files without elevated privileges. Also, If Microsoft stored the deployed files in the “All Users” folder, they would have to figure out what to do if UserA was logged on using the application, and then UserB logged on and there was an update available. Do you kick off UserA?

Install Clickonce Application From Command Line

Do you forego the update because UserA is already running the application? What is UserA always leaves his account logged on? How will you ever do an update?This request has been passed on to Microsoft, but I haven’t heard of any plans to include a change to this in.NET 4.0, so I wouldn’t expect any quick results. Doing an all-users install is counter to the design goals of ClickOnce deployment, so I think it’s going to be something everyone has to live with, at least for now. Using XCopy or a setup & deployment package and rolling your own incremental update methodology would be the way to go if you absolutely have to have an All Users installation.Tags:,Posted in,. Search:.

Pages. Archives. Categories. Blogroll.RT @: @ Then publicly release all your interactions with the Ukraine. Let’s have those tapes too. Show us how you neve tweeted.RT @: The NRA served as a “foreign asset” to Russian officials in the lead-up to the 2016 election. It is a corrupt political or tweeted.RT @: Today is historic.California just signed into law the strongest renter protections in the NATION.No one should be forc tweeted.RT @: “But missing the point entirely, DeGeneres framed the issue as simply a matter of her hanging out with someone with diff tweeted.RT @: Making White House staffers take lie detector tests seems like a dangerous precedent for Donald Trump, of all people, to se tweeted.