Custom App.Config File Location

S

sebastian.dau

Hello NG.

we are developing a .NET system using COM Interop with Excel VBA.

The .NET AppDomain Base Path is set to the Excel.Exe Path by default.
This is the location where the Runtime starts probing for reference
assemblies.

How can you avoid to copy out ref asms into Excels bin folder without
deploying it into GAC?

How can you take control over the BasePath of the VBA AppDomain to set
it to the location of the Active Excel Sheet instead?

Thanks in advance for your support!

Greetings, Sebastian Dau.
 
M

Mariusz Gorzoch

Hi

You can try to create new application domain and just configure application
base path. Have look at the code below:

AppDomainSetup set = new AppDomainSetup();
set.ApplicationBase=@"c:\";
AppDomain ap = AppDomain.CreateDomain("new",null,set);
ap.ExecuteAssembly(@"C:\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe");
Console.WriteLine(ap.BaseDirectory);

so, I believe that in your case you should twek-up "set.ApplicationBase"
property to be the excel folder one, and load your application (which is
referencing excel files) by providing path to it with use of
ap.ExectureAssembly.

Hope that it make sens

best regards
Mariusz, Gorzoch
 

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