ClickOnce application and Application Assembly Path

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
 
M

miher

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top