473,473 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to change the config file to be used by the current application?

Hello,

I have an assembly that is used by a VB6 application. This application can
be a normal exe or an ActiveX (called through CCW).
My assembly needs to get extra info from a config file. In order to hide it
from the VB client, I want to link the config file to my assembly and not to
the applicaction. In that sense, the config file will be called
<myAssemblyName>.dll.config and will be located in the same directory as my
assembly dll.

I tried to use the
"AppDomain.CurrentDomain.SetupInformation.Configur ationFile" property to
amend the config file to be used. However, it does not work (According to
documentation: This property cannot be changed after the AppDomain has
finished its first bind)
My problem is that my assembly makes use of
"ConfigurationSettings.AppSettings[strKey]" to blindly get keys from the
configuration file and I can not really modify the part of the code that
retrieve info from the config file. Furtermore, I also use the config file
to get info about switches and listener
Is there a way to force my assembly to use a custom config file?
Thanks,
José

Jul 19 '05 #1
1 7743
I went a step further...

Using AppDomain, I was able to use another config file.
In fact, I load my class in another AppDomain for which I can specify the
config file to use and then I forward the call to the newly created class
(see code below if needed).
This work fine if the client is managed. For an unmanaged client, this works
if you place all the dlls in the same directory...
At the present, the unmanaged part must be an exe and it is not possible to
run it from the VB6 IDE.. This will make problem when
trying to probe the dll :-((
A point that is still open to me is how to debug the managed part when
client is unmanaged
José


======================

//create the config settings object
AppDomainSetup setup = new AppDomainSetup();

//work out what the config file name and app base are
FileInfo fileInfo = new
FileInfo(Assembly.GetExecutingAssembly().Location) ;
string appBase = fileInfo.DirectoryName;
string configFile = fileInfo.Name + ".config";

//set the app base and the config file
setup.ApplicationBase = appBase;
setup.ConfigurationFile = configFile;

//create the domain
gAppDomain = AppDomain.CreateDomain ("ExportedView: " +
Guid.NewGuid().ToString(), null, setup);

//create the type inside the domain, and get the interface to it
gUFSStatusAccessDomain = (UFSStatusAccessDomain)
gAppDomain.CreateInstanceAndUnwrap(
Assembly.GetExecutingAssembly().FullName,
typeof(UFSStatusAccessDomain).FullName);
-------------
public class UFSStatusAccessDomain : MarshalByRefObject
{ ....}

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...
Hello,

I have an assembly that is used by a VB6 application. This application can
be a normal exe or an ActiveX (called through CCW).
My assembly needs to get extra info from a config file. In order to hide it from the VB client, I want to link the config file to my assembly and not to the applicaction. In that sense, the config file will be called
<myAssemblyName>.dll.config and will be located in the same directory as my assembly dll.

I tried to use the
"AppDomain.CurrentDomain.SetupInformation.Configur ationFile" property to
amend the config file to be used. However, it does not work (According to
documentation: This property cannot be changed after the AppDomain has
finished its first bind)
My problem is that my assembly makes use of
"ConfigurationSettings.AppSettings[strKey]" to blindly get keys from the
configuration file and I can not really modify the part of the code that
retrieve info from the config file. Furtermore, I also use the config file
to get info about switches and listener
Is there a way to force my assembly to use a custom config file?
Thanks,
José


Jul 19 '05 #2

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

Similar topics

1
by: José Joye | last post by:
Hello, I have an assembly that is used by a VB6 application. This application can be a normal exe or an ActiveX (called through CCW). My assembly needs to get extra info from a config file. In...
2
by: Torrance S. | last post by:
Hi, I have a class in an assembly that references a value in web.config like this: <appSettings> <add key="mykey" value="myvalue"/> </appSettings> string temp =...
4
by: tommy | last post by:
hello everbody, i write a little asp-application with forms-authentication. i copy my aspx-files with web.config to my webspace and i get the error above... i tried to set the...
5
by: who be dat? | last post by:
Hello all. I'm writing an application that is writing trace information that can be viewed in trace.axd. I would like to rename this and use a different name specific to my application. I know...
2
by: Joel D Kraft | last post by:
I'm using controls in my ASP.NET application from a couple of vendors. Between the vendors and thier versioning, I've set up subfolders under my bin directory: bin bin\Infragistics\v5.2...
4
by: Ravi Ambros Wallau | last post by:
Hi: We developed a set of ASP.NET Web Applications that never runs in stand-alone mode, but always inside a portal (Rainbow Portal). All modules are copied on that portal. My question is: load...
6
by: NickP | last post by:
Hi there, I am implementing a simple "/U" command line argument for a .NET application that instructs the application to delete the following folders... ...
0
by: Alias | last post by:
Hi - I have a site that runs on a development and production server. I'd like to programmatically change the connection string the provider uses in the web.config file and have the provider use...
0
by: Michael Bray | last post by:
I've found a change in SP1 that doesn't seem to make sense to me, but seems to be there nonetheless. The situation is this... I have an application that stores it's configuration in a file in...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.