App.Config from a different EXE

P

PromisedOyster

We have an executable that uses an App.Config file to hold things such
as database connection strings etc.

We now want to write a wrapper DLL around that executable to expose
functionality to integrate with another app.

Therefore we aim to have one new executable talking to the wrapper DLL
that in turn talks to the original app. Although the original app is
an executable, it can be treated like a DLL.

Ideally what I want is for the new executable to use the keys in the
App.config from the original application that is somehow set from the
wrapper DLL.

ie in the new application it will call something like:

WrapperDLL.Init();


The method Init() in wrapper DLL will in turn get the App.Config from
the original application and set it for the new executable:

ie something like:

class WrapperDLL
{
void Init()
{
Configuration c =
ConfigurationManager.OpenExeConfiguration("test.exe");
// Then somehow use this configuration as the current App.Config ??
This is where I am lost
}
}


How best can I achieve this?
 
I

Ignacio Machin ( .NET/ C# MVP )

We have an executable that uses an App.Config file to hold things such
as database connection strings etc.

We now want to write a wrapper DLL around that executable to expose
functionality to integrate with another app.

How are you planning to do this?
 
P

PromisedOyster

How are you planning to do this?

What we have is as follows:

- OtherApplication.exe - this is a third party product that needs to
access functionality in our application
- Wrapper.DLL - this is a wrapper around our application and only
exposes certain classes and methods that are of interest to the
OtherApplication.
- OurApplication.exe - this is our application that contains an
app.config which contains info such as database connection strings

The wrapper DLL is simply another .NET assembly that has a reference
to OurApplication .NET assembly (which happens to be an executable).
Only a handful of new classes and methods are in the wrapper DLL and
are more in-tune with the functionality that the other application
requires rather than giving them details on accessing the main
executable.

The issue is that OurApplication.exe has the app.config that contains
things such as the database connection strings. This app.config needs
to be accessed from the wrapper DLL and then used as the app.config
for the OtherApplication that is accessing our application via the
warapper.

Was this the sort of information you were after?
 

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