Custom App.Config File Location

  • Thread starter Thread starter sebastian.dau
  • Start date Start date
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.
 
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
 
Back
Top