473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Application Object in different AppDomain

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.
Jan 4 '08 #1
3 2216
Take a look at the properties you can set on the AppDomain itself, such as
PrivateBinPath with the Setup class.

http://msdn2.microsoft.com/en-us/lib...tebinpath.aspx
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"Olie" wrote:
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.
Jan 4 '08 #2
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);
Jan 4 '08 #3
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.
Jan 4 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Daylor | last post by:
i have 1 main winapplication. 3 services ,each in dll. each service is created for telephony user. each service is destroyed when the telephony user is hangUp. is there a way to recompile...
8
by: nickdu | last post by:
I'm trying to isolate "applications" into their own application domain within a single process. I've quoted applications because it's a logical representation of an application. Basically it...
4
by: Woland | last post by:
Hi, I have many virtual directory with my web app. I'd like to create one exe appliaction to administrating these web apps. Is it possible to access Application object of web appliaction from...
3
by: SL | last post by:
All, As I understand it, a single application (i.e. IIS virtual directory) in ASP.NET may in fact have more than one corresponding HttpApplicationState object (more or less one per server...
9
by: craigkenisston | last post by:
Hi, I'm starting my first asp.net application and I decided to put the users preferences in a static class. I thought, the static class would be just seen by current session, but it seems it...
15
by: Untitled | last post by:
I have an ASP .NET web application that displays information. At the same time, i have a web service that collects information from various client applications. This data needs to be processed...
5
by: Pint | last post by:
Is there a way to prevent my web application from shuting down if I don't have access to machine.config? Thanks, Pint
4
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst...
6
by: Tony Johansson | last post by:
Hello! We have a C#.ASP.NET application that runs on a IIS 6. The application contains actually several asp pages but there is no GUI. The application receive an xml file that is processed....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.