473,554 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shared app.config

This situation requres many exes to be sitting on a network share. I would
like all of these to use the same app.config file, which will be stored in
the same location on the network. A quick test though gave me this
exception:

System.InvalidO perationExcepti on: The key 'ConnectionStri ng' does not exist
in the appSettings configuration section.
at System.Configur ation.AppSettin gsReader.GetVal ue(String key, Type type)
at test_appconfig. Form1.FromAppli cationConfig(St ring Key) in
F:\VB.NET\junk\ test_appconfig\ test_appconfig\ Form1.vb:line 62
The program '[2808] test_appconfig. exe' has exited with code 0 (0x0).

What's the best way to share the app.config in this common network folder?
Thanks, Eric
Public Function FromApplication Config(ByVal Key As String) As String
Try
Dim reader As New AppSettingsRead er
Return CStr(reader.Get Value(Key, GetType(String) ))
Catch ex As Exception
MessageBox.Show (ex.Message.ToS tring & vbCrLf & _
ex.Source.ToStr ing & vbCrLf & _
ex.StackTrace.T oString, "Function: FromApplication Config Exception",
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)
End Try
End Function
Nov 20 '05 #1
5 6500
Assign them the same appDomain. I "believe" thats what is used to read the
app.config file... I could be wrong on that. But tests that I've done show
it.

-CJ

"Eric Sabine" <mopar41@____h_ o_t_m_a_i_l_._S cPoAmM> wrote in message
news:OF******** ******@TK2MSFTN GP12.phx.gbl...
This situation requres many exes to be sitting on a network share. I would like all of these to use the same app.config file, which will be stored in
the same location on the network. A quick test though gave me this
exception:

System.InvalidO perationExcepti on: The key 'ConnectionStri ng' does not exist in the appSettings configuration section.
at System.Configur ation.AppSettin gsReader.GetVal ue(String key, Type type)
at test_appconfig. Form1.FromAppli cationConfig(St ring Key) in
F:\VB.NET\junk\ test_appconfig\ test_appconfig\ Form1.vb:line 62
The program '[2808] test_appconfig. exe' has exited with code 0 (0x0).

What's the best way to share the app.config in this common network folder?
Thanks, Eric
Public Function FromApplication Config(ByVal Key As String) As String
Try
Dim reader As New AppSettingsRead er
Return CStr(reader.Get Value(Key, GetType(String) ))
Catch ex As Exception
MessageBox.Show (ex.Message.ToS tring & vbCrLf & _
ex.Source.ToStr ing & vbCrLf & _
ex.StackTrace.T oString, "Function: FromApplication Config Exception",
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)
End Try
End Function

Nov 20 '05 #2
Thanks CJ, so then I would be creating a new appdomain in my sub main? In
what way though do I instruct each exe to share this appdomain? Are the
parameters for itself somehow loaded from some additional universal file.
This is new territory for me.

Could you share and representative code please?

Eric
"CJ Taylor" <no****@blowgoa ts.com> wrote in message
news:10******** *****@corp.supe rnews.com...
Assign them the same appDomain. I "believe" thats what is used to read the app.config file... I could be wrong on that. But tests that I've done show it.

-CJ

"Eric Sabine" <mopar41@____h_ o_t_m_a_i_l_._S cPoAmM> wrote in message
news:OF******** ******@TK2MSFTN GP12.phx.gbl...
This situation requres many exes to be sitting on a network share. I

would
like all of these to use the same app.config file, which will be stored in the same location on the network. A quick test though gave me this
exception:

System.InvalidO perationExcepti on: The key 'ConnectionStri ng' does not

exist
in the appSettings configuration section.
at System.Configur ation.AppSettin gsReader.GetVal ue(String key, Type type) at test_appconfig. Form1.FromAppli cationConfig(St ring Key) in
F:\VB.NET\junk\ test_appconfig\ test_appconfig\ Form1.vb:line 62
The program '[2808] test_appconfig. exe' has exited with code 0 (0x0).

What's the best way to share the app.config in this common network folder? Thanks, Eric
Public Function FromApplication Config(ByVal Key As String) As String
Try
Dim reader As New AppSettingsRead er
Return CStr(reader.Get Value(Key, GetType(String) ))
Catch ex As Exception
MessageBox.Show (ex.Message.ToS tring & vbCrLf & _
ex.Source.ToStr ing & vbCrLf & _
ex.StackTrace.T oString, "Function: FromApplication Config Exception",
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)
End Try
End Function


Nov 20 '05 #3
Your sub main creates an appdomain nonetheless on a current thread with the
same name as the executable.

So it looks like you can create a new Domain... and run
AppDomain.Execu teAssembly() and get the desired results. I have never
actually done this, I'm just looking at things and think it can do it..

But hey, not a lot of code to test out..

Lookup AppDomain.Execu teAssembly in your help file it gives an example.

-CJ

"Eric Sabine" <mopar41@____h_ o_t_m_a_i_l_._S cPoAmM> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Thanks CJ, so then I would be creating a new appdomain in my sub main? In
what way though do I instruct each exe to share this appdomain? Are the
parameters for itself somehow loaded from some additional universal file.
This is new territory for me.

Could you share and representative code please?

Eric
"CJ Taylor" <no****@blowgoa ts.com> wrote in message
news:10******** *****@corp.supe rnews.com...
Assign them the same appDomain. I "believe" thats what is used to read the
app.config file... I could be wrong on that. But tests that I've done

show
it.

-CJ

"Eric Sabine" <mopar41@____h_ o_t_m_a_i_l_._S cPoAmM> wrote in message
news:OF******** ******@TK2MSFTN GP12.phx.gbl...
This situation requres many exes to be sitting on a network share. I

would
like all of these to use the same app.config file, which will be
stored in the same location on the network. A quick test though gave me this
exception:

System.InvalidO perationExcepti on: The key 'ConnectionStri ng' does not

exist
in the appSettings configuration section.
at System.Configur ation.AppSettin gsReader.GetVal ue(String key, Type type) at test_appconfig. Form1.FromAppli cationConfig(St ring Key) in
F:\VB.NET\junk\ test_appconfig\ test_appconfig\ Form1.vb:line 62
The program '[2808] test_appconfig. exe' has exited with code 0 (0x0).

What's the best way to share the app.config in this common network folder? Thanks, Eric
Public Function FromApplication Config(ByVal Key As String) As String
Try
Dim reader As New AppSettingsRead er
Return CStr(reader.Get Value(Key, GetType(String) ))
Catch ex As Exception
MessageBox.Show (ex.Message.ToS tring & vbCrLf & _
ex.Source.ToStr ing & vbCrLf & _
ex.StackTrace.T oString, "Function: FromApplication Config Exception",
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)
End Try
End Function



Nov 20 '05 #4
The application configuration file must reside in the application directory
and must be named the same as the exe file, with a .config extension. For
example, if your application exe is "test.exe" the config file will be
"test.exe.confi g". The simplest way to solve your problem is to dynamically
copy the app.config master copy to the application directory for each
application, renaming it appropriately when the application starts. For
example, this code will work. Note that it only works as written in
*release* mode, not in debug mode. However, you can probably add an ifdef
and change the pathname for the copied file to make it work in either--I
didn't test that.

Also note that, as written, there's a hard-coded path to the master
app.config file in the code, which is generally a bad idea. You'd be better
off retreiving the master pathname from the Registry, from some text file,
passing it in as a startup parameter, or getting it from a database

Put this code in your startup form load or in the module containing Sub
Main, changing the master-location path and "someKey" appropriately.
Imports System.IO
Imports System.Reflecti on
' at startup in *RELEASE* mode
' get the location of this executable
Dim appLocation As String = [Assembly].GetExecutingAs sembly.Location
File.Copy("mast er-location\app.co nfig", appLocation & ".config", True)
' read the config file (proof that it works)
'
Debug.WriteLine (System.Configu ration.Configur ationSettings.A ppSettings.Get( "
someKey"))

"Eric Sabine" <mopar41@____h_ o_t_m_a_i_l_._S cPoAmM> wrote in message
news:OF******** ******@TK2MSFTN GP12.phx.gbl...
This situation requres many exes to be sitting on a network share. I would like all of these to use the same app.config file, which will be stored in
the same location on the network. A quick test though gave me this
exception:

System.InvalidO perationExcepti on: The key 'ConnectionStri ng' does not exist in the appSettings configuration section.
at System.Configur ation.AppSettin gsReader.GetVal ue(String key, Type type)
at test_appconfig. Form1.FromAppli cationConfig(St ring Key) in
F:\VB.NET\junk\ test_appconfig\ test_appconfig\ Form1.vb:line 62
The program '[2808] test_appconfig. exe' has exited with code 0 (0x0).

What's the best way to share the app.config in this common network folder?
Thanks, Eric
Public Function FromApplication Config(ByVal Key As String) As String
Try
Dim reader As New AppSettingsRead er
Return CStr(reader.Get Value(Key, GetType(String) ))
Catch ex As Exception
MessageBox.Show (ex.Message.ToS tring & vbCrLf & _
ex.Source.ToStr ing & vbCrLf & _
ex.StackTrace.T oString, "Function: FromApplication Config Exception",
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)
End Try
End Function

Nov 20 '05 #5
Eric,

You can put the settings in the machine.config file.
Its located in the CONFIG directory of the runtime install path
(System.Web.Hos ting.SimpleWork erRequest.Machi neConfigPath Property will
return the path)
machine.config already contains an <appSettings> although it is commented
out
AppSettingsRead er first checks this file before checking the applications
configuration file

Stephen

"Eric Sabine" <mopar41@____h_ o_t_m_a_i_l_._S cPoAmM> wrote in message
news:OF******** ******@TK2MSFTN GP12.phx.gbl...
This situation requres many exes to be sitting on a network share. I would like all of these to use the same app.config file, which will be stored in
the same location on the network. A quick test though gave me this
exception:

System.InvalidO perationExcepti on: The key 'ConnectionStri ng' does not exist in the appSettings configuration section.
at System.Configur ation.AppSettin gsReader.GetVal ue(String key, Type type)
at test_appconfig. Form1.FromAppli cationConfig(St ring Key) in
F:\VB.NET\junk\ test_appconfig\ test_appconfig\ Form1.vb:line 62
The program '[2808] test_appconfig. exe' has exited with code 0 (0x0).

What's the best way to share the app.config in this common network folder?
Thanks, Eric
Public Function FromApplication Config(ByVal Key As String) As String
Try
Dim reader As New AppSettingsRead er
Return CStr(reader.Get Value(Key, GetType(String) ))
Catch ex As Exception
MessageBox.Show (ex.Message.ToS tring & vbCrLf & _
ex.Source.ToStr ing & vbCrLf & _
ex.StackTrace.T oString, "Function: FromApplication Config Exception",
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation)
End Try
End Function

Nov 20 '05 #6

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

Similar topics

0
2260
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled with the Sun Compiler version 8. My problem is that EVERYTHING builds great EXCEPT that the 6b distribution of JPEG will NOT build a shared...
0
1140
by: John Dalberg | last post by:
I am trying to lock down file access of some sites in a shared hosting environment so that different users can only access their own site's directory with their asp.net code. However there's a problem with some aspnet user access. After some experimenting with ntfs permissions, I noticed that any asp.net enabled site *must* have asp.net...
9
4168
by: Invalidlastname | last post by:
Hi, We developed some assemblies which use EnterpriseServices queued components. In order to use EnterpriseServices, these assemblies need to be installed into GAC. I used the pre-build and post-build events to automate GAC installation processes and the asp.net application has "copy to local" set to false for the references of these shared...
3
1797
by: Sam-I-Am | last post by:
Hi all I have a common shared assembly in intalled in the GAC: myco.myprod.common.dll I have set a reference to this assembly in a asp.net web application. I have config sections in my web.config like the following: <configSections> <section name="Configuration" type="myco.myprod.common.Configuration, myco.myprod.common" />...
27
2533
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: Mensaje de error del analizador: We can't load the type 'JULIAN.Global'.
33
3447
by: Joe Fallon | last post by:
1. I have a Base class that has a certain amount of functionality. 2. Then I have a CodeSmith generated class that inherits from the Base class and adds functionality. 3. Since I want to be able to re-generate the classes on level 2 I have a 3rd level that inherits from them and implements specific hand coded methods. 4. My colleague asked...
4
2026
by: a | last post by:
Hello Gang, I am in a bit of confusion regarding a half completed application I am writing. It is an MDI app, so I have a main form (frmMain) that is always open. I am looking for a 'Best Practice' here. I have a class (config.vb) that manages an XML file with the applications configuration settings. I need to access it from many...
1
1385
by: QT | last post by:
Hi. Is it possible to use configuration files with a shared add-in component? I have added one to my solution for the add-in, but I can't pick up the values from my config file. If my component's name is MyComponent.dll, my config file is named MyComponent.config. Here is the file contents: <?xml version="1.0" encoding="utf-8" ?>...
4
3345
by: Rubbrecht Philippe | last post by:
Hi there, I would like to develop an interface that when implemented in a class requires a number of shared properties or methods to be available. It seems a Shared Member can not be used as interface member implementation?! Is there a workaround to this problem?! Best regards, Philippe Rubbrecht
0
2213
by: vikramp | last post by:
Hi, I am storing theme in web.config using <pages theme="mytheme"/>. I am then using the following code to read it from my webpage: Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); PagesSection section = (PagesSection)config.GetSection("system.web/pages"); string currenttheme = section.Theme;
0
7605
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...
0
7808
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. ...
0
8047
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...
1
7570
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...
0
7893
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...
0
3556
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2022
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
1
1141
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
845
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...

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.