Application Object in different AppDomain

O

Olie

I am trying to run an application by creating a new AppDomain and then
running the executable in the new domain. This works perfectly but
when the application runs it is looking in the wrong directory for
some of the files. I have found out this is because the
Application.ExecutablePath has the path of the original app and not
that of the application domain.

Is there any way to change this so Application.ExecutablePath returns
the domain path.

I fear the answer is no so my next question is how do you start an
application in a different folder while still gaining access to the
created objects and forms?

I do not have access to the executing assembly so I can not change it
to not use Application.ExecutablePath.
 
O

Olie

AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = Path.GetDirectoryName(fileName);
setup.ApplicationName = Path.GetFileName(fileName);
setup.ShadowCopyDirectories = setup.ApplicationBase;
setup.CachePath = setup.ApplicationBase;
setup.PrivateBinPath = setup.ApplicationBase;
setup.ConfigurationFile = configFileName;

AppDomain domain = AppDomain.CreateDomain(domainName,
null, setup);
 
O

Olie

Thanks but tried that :)

AppDomainSetup setup = new AppDomainSetup();
setup.ApplicationBase = Path.GetDirectoryName(fileName);
setup.ApplicationName = Path.GetFileName(fileName);
setup.ShadowCopyDirectories = setup.ApplicationBase;
setup.CachePath = setup.ApplicationBase;
setup.PrivateBinPath = setup.ApplicationBase;
setup.ConfigurationFile = configFileName;

AppDomain domain = AppDomain.CreateDomain(domainName,
null, setup);

filename is the name of the executing assembly.
 

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