SuppaiKamo
SuppaiKamo

Reputation: 285

How to call a clickonce deployed application from another application in VB.NET?

A system is composed of a outlook ribbon addin and a windows forms application written in VB.NET. Both deployed using ClickOnce deployment. What I need is to be able to call the windows forms application from the outlook ribbon. How can I locate the windows forms application on the users machine? Does Windows store some information about where it is located that can be referenced by the name of the application?

Upvotes: 0

Views: 1839

Answers (2)

Isidoros Moulas
Isidoros Moulas

Reputation: 697

Well, if you call:

System.Diagnostics.Process.Start("http://example.com/myapp.application")

will open the browser to download the myapp.application.

It's better to download the file to a local folder and afterwards to run/execute the file.

 Public Sub ApplicationUpgrade()
    Dim docFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
    Dim destFile As String = docFolder & "\myapp.application"
    If System.IO.File.Exists(destFile) Then
        System.IO.File.Delete(destFile)
    End If

    My.Computer.Network.DownloadFile("http://example.com/myapp.application", destFile)

    If System.IO.File.Exists(destFile) Then
        System.Diagnostics.Process.Start(destFile)
        Application.Exit()
    End If

End Sub

The code will download the .application file to the documents folder and auto launch the file. This will cause the automatic installation of the upgrade.

Upvotes: 0

Nelson Hoover
Nelson Hoover

Reputation: 169

You could, if your Windows Forms application is deployed from a URL, simply call the URL it is deployed from, in your ribbon add-in, and it'll start it no matter where it's actually installed on your HDD.

Like this:

System.Diagnostics.Process.Start("http://mydomain.com/myapp.application")

Here is a more detailed explanation of setting up a shortcut to a Click-Once deployed application: http://keithelder.net/2009/04/18/how-to-run-a-clickonce-application-on-startup/

Upvotes: 1

Related Questions