Search code examples
c#clickonce

Determine if App is running as a 'clickonce' application


I am in the process of writing a library (c# .net 4.0) for use in a number of applications. One of the requirements is that the library returns slightly different results to calls depending on whether or not the application is deployed and running via clickonce.

I've had a search around but cannot find any way that an assembly can determine if the 'hosting' application is clickonce deployed.

Any pointers would be appreciated.


Solution

  • Add reference to System.Deployment, after that you can use:

    Application.ApplicationDeployment.IsNetworkDeployed
    

    If you need to pass arguments to application, then use:

    var args = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;