473,383 Members | 1,748 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,383 software developers and data experts.

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é

Nov 15 '05 #1
1 1089
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é


Nov 15 '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: Sam | last post by:
Inquiry? -------- I would like to authenticate all subdirectory via asp.net at Windows Server 2003 and IIS 6.0 but it prompt an error message as shown as below: Runtime Error? --------------...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.