ClickOnce application and Application Assembly Path

  • Thread starter Thread starter CraigH
  • Start date Start date
C

CraigH

I've recently updated a WinForms application (using .NET 3.5) to utilise
ClickOnce features to perform version updates at startup.

On launch, the existing application scanned it's installation folder for
plugin type assemblies that would be loaded if they were present and met
certain criteria.

After performing an update of the application (at launch) via ClickOnce, the
ExecutingAssembly seems to be pointing to the update location which is
located on a network path, resulting in a SecurityException when attempting
to access the CodeBase property of the ExecutingAssembly.

Assembly.GetExecutingAssembly().GetName().CodeBase

Is there an alternative way of identifying your executing location when
using ClickOnce so that I can search for assembly files in my application
folder?

Thanks
 
Hi,

This should work for simple assemblies.

string deploymentDir = string.Empty;
if
(System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
deploymentDir =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

Hope You find this useful.
-Zsolt
 
Back
Top