473,796 Members | 2,632 Online
Bytes | Software Development & Data Engineering Community
+ 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.Curr entDomain.Setup Information.Con figurationFile" 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
"ConfigurationS ettings.AppSett ings[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 7756
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(Assemb ly.GetExecuting Assembly().Loca tion);
string appBase = fileInfo.Direct oryName;
string configFile = fileInfo.Name + ".config";

//set the app base and the config file
setup.Applicati onBase = appBase;
setup.Configura tionFile = configFile;

//create the domain
gAppDomain = AppDomain.Creat eDomain ("ExportedVi ew: " +
Guid.NewGuid(). ToString(), null, setup);

//create the type inside the domain, and get the interface to it
gUFSStatusAcces sDomain = (UFSStatusAcces sDomain)
gAppDomain.Crea teInstanceAndUn wrap(
Assembly.GetExe cutingAssembly( ).FullName,
typeof(UFSStatu sAccessDomain). FullName);
-------------
public class UFSStatusAccess Domain : MarshalByRefObj ect
{ ....}

"José Joye" <jo*******@KILL THESPAMSbluewin .ch> wrote in message
news:e2******** ******@TK2MSFTN GP09.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.Curr entDomain.Setup Information.Con figurationFile" 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
"ConfigurationS ettings.AppSett ings[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
1106
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 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.
2
3193
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 = System.Configuration.ConfigurationSettings.AppSettings.Get("mykey");
4
5393
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 custom-errors-tag ="off" but nothing happens.... what is my failure????
5
2938
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 the name of this is set in machine.config. I was hoping it would be possible to change this in web.config. I got it to work, kind of. Good news is I can change the name in my web.config file. Bad news is that trace.axd still works meaning I can...
2
2394
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 bin\RadControls\v5.3 Under 2.0b2, I had the following setup in my web.config: <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
4
2215
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 time takes, sometimes, three or four of minutes in a medium-level machine (a PIII 1.5 Ghz), when the binary contents are changed, or if the time of last modification of the web.config file is changed. An application that runs in "stand-alone" mode...
6
1427
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... My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData The application deletes these folders successfully then exits. Even
0
3775
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 the updated string. I am able to successfully change the string using this code in the Application_Start method of the Global.asax file: Dim csNew As ConnectionStringSettings
0
1054
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 the Application directory. If the application is called "MyApp.exe", the configuration file is "MyApp.config". Note that this is not the same as "MyApp.exe.config" which is where the .NET-based XML-format configuration normally goes. This...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10461
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10239
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10190
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10019
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6796
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4122
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.