Shared app.config

VB.NET

    Next

  • 1. Newbe ValueMember property question: Found. selectedValue property
    "Bruce A. Julseth" < XXXX@XXXXX.COM > wrote in message news:% XXXX@XXXXX.COM ... > Sorry. The other post got sent before I was complete. > > Does the ValueMember property in the ComboBox work like the DisplayMember > property. For example, if I set the properties: > > comboBox1.DataSource = dataSet1 > comboBox1.DisplayMember ="Employees.LastName" > comboBox1.ValueMember = "Employees.EmployeeID" > > If I select from the box a "LastName", I can retrive that selected name. How > do I retrieve the "ValueMember" setting, ie the "EmployeeID" for the > selected "LastName." > > Or, isn't that the way ValueMember works? Is so, how does it work and how is > it used. I'm looking for a replacement for the VB.Compatibility > "VB6.GetItemData." > > Thank you.. > > Bruce > > Never mind. I found the answer.. selectedValue property Thanks.. Bruce
  • 2. Disregad. Go to message sent a little later.
    "Bruce A. Julseth" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ... > Does the ValueMember property in the ComboBox work like the DisplayMember > property. For example, if I set the properties: > > > comboBox1.DataSource = dataSet1;comboBox1.DisplayMember = > "Employees.LastName";comboBox1.ValueMember = "Employees.EmployeeID"; > " > >
  • 3. Newbe ValueMember property question
    Sorry. The other post got sent before I was complete. Does the ValueMember property in the ComboBox work like the DisplayMember property. For example, if I set the properties: comboBox1.DataSource = dataSet1 comboBox1.DisplayMember ="Employees.LastName" comboBox1.ValueMember = "Employees.EmployeeID" If I select from the box a "LastName", I can retrive that selected name. How do I retrieve the "ValueMember" setting, ie the "EmployeeID" for the selected "LastName." Or, isn't that the way ValueMember works? Is so, how does it work and how is it used. I'm looking for a replacement for the VB.Compatibility "VB6.GetItemData." Thank you.. Bruce
  • 4. ValueMember property
    Does the ValueMember property in the ComboBox work like the DisplayMember property. For example, if I set the properties: comboBox1.DataSource = dataSet1;comboBox1.DisplayMember = "Employees.LastName";comboBox1.ValueMember = "Employees.EmployeeID"; "

Shared app.config

Postby Eric Sabine » Sun, 07 Mar 2004 01:21:54 GMT

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.InvalidOperationException: The key 'ConnectionString' does not exist
in the appSettings configuration section.
at System.Configuration.AppSettingsReader.GetValue(String key, Type type)
at test_appconfig.Form1.FromApplicationConfig(String 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 FromApplicationConfig(ByVal Key As String) As String
Try
Dim reader As New AppSettingsReader
Return CStr(reader.GetValue(Key, GetType(String)))
Catch ex As Exception
MessageBox.Show(ex.Message.ToString & vbCrLf & _
ex.Source.ToString & vbCrLf & _
ex.StackTrace.ToString, "Function: FromApplicationConfig Exception",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Function



Re: Shared app.config

Postby CJ Taylor » Sun, 07 Mar 2004 01:43:41 GMT

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





would
exist



Re: Shared app.config

Postby Eric Sabine » Sun, 07 Mar 2004 02:18:08 GMT

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






the
show



in
type)
folder?



Re: Shared app.config

Postby CJ Taylor » Sun, 07 Mar 2004 02:29:16 GMT

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.ExecuteAssembly() 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.ExecuteAssembly in your help file it gives an example.

-CJ











stored



Re: Shared app.config

Postby Russell Jones » Sun, 07 Mar 2004 03:34:06 GMT

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.config". 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.Reflection
' at startup in *RELEASE* mode
' get the location of this executable
Dim appLocation As String = [Assembly].GetExecutingAssembly.Location
File.Copy("master-location\app.config", appLocation & ".config", True)
' read the config file (proof that it works)
'
Debug.WriteLine(System.Configuration.ConfigurationSettings.AppSettings.Get("
someKey"))







would
exist



Re: Shared app.config

Postby Stephen Muecke » Sun, 07 Mar 2004 07:31:33 GMT

Eric,

You can put the settings in the machine.config file.
Its located in the CONFIG directory of the runtime install path
(System.Web.Hosting.SimpleWorkerRequest.MachineConfigPath Property will
return the path)
machine.config already contains an <appSettings> although it is commented
out
AppSettingsReader first checks this file before checking the applications
configuration file

Stephen





would
exist



Similar Threads:

1.How to use a shared app.config file?

.Net 2.0 I have a variety of console applications that run continuiously in 
parallel using the file watcher as an event queue.  In addition, I have an 
ASP.Net website that needs to access the same key/value pairs as the console 
apps.  I have configured a separate app.config file for each console app and 
have a separate web.config file for the web site.  To simplify the 
configuration, I would like to use a single app.config file that can be 
accessed by each application.  Is there a simple way to do this?

Thanks, 
-- 
Tim Meagher

2.Using config files other than app.config for different configurations

I have created two configurations. One is called Release-Internal and
one is called Release-External.  I also have two config files named
Internal.config and External.config.  The difference in the files is
that the server locations included within each file are either the
local internal addresses or the external public addresses.  I've set
the "override file" property in the configuration option property page
to be Interal.config for Release-Internal and to External.config for
Release.external.  The effect of that seems to be when you build a
deployment package then the correct .config file is deployed as
AppName.exe.config.  My problem with that is that I often rebuild a
project without deploying a new MSI file.  What I would like to have
happen is that .NET detects that since I'm building the project in
Release-External to use the External.config file to create an
AppName.exe.config file, and vice-versa.  However, when building the
projects, .NET will only use App.Config.  If there is no file named
App.Config it won't create any file named AppName.exe.config.  How are
others getting around this?

Thanks in advance.
Matthew

3.Wiring up an App.Config file - deploying the App.Config file

Hello,

(Is this the proper newsgroup?)

=== Background ===
I am building a solution with two projects.

One project is my data access layer which contains my DataSet as an xsd 
file. The XSD file was built by draging tables from the Data Sources pane. 
Auto-generated code created the files associated wtih the XSD file (xss, 
xsc, cs).

The other project has a reference to the data access layer project and 
contains my windows forms.

=== My Goal === (My two questions further down address parts of this goal.)
I want to add an app config file to the solution and have it contain the 
connectionstring. I want to be able to edit this App.Config file after 
deployment so that I can connect to the desired target database.

=== Question #1 ===
This question is about adding an App.Config file after the XSD file is 
already configured:

When I create an XSD file after I add an App.Config file the 
connectionString is automatically added to the config file and the XSD is 
automatically wired up to the App.Config file.

However, when the XSD file is created first teh XSD and the App.Config file 
are independant form one another - no automatic wiring occurs. How can I get 
the App.Config file wired up to the XSD file? - I cannot edit any of the 
files associated with the XSD file because the code is auto-generated.

#1) How do I add a App.Config file to a data access layer project with an 
existing XSD file and have them appropriately wired up to each other?

=== Question #2 ===
This question is about deployment of the application when there is an 
App.Config file in the data access layer:

The following test solution scenario illustrates my problem:

I created a test solution where I added a data access layer project (DAL) 
and added the App.Config file before building the XSD file. I built the XSD 
file by adding a table to the design surface. (the app.config and the xsd 
are automatically wired up properly.) Then I added a windows form project 
(WinFrmPrj) and add a reference to the DAL and added a form with a 
dataGridView and wired it up to display a table of data. I built a Release 
version of the project.

Looking at the respective bin\release folder structures I see the following:

DAL\bin\Release
- DAL.dll
- DAL.dll.config
- DAL.pdb

WinFrmPrj\bin\release
- DAL.dll
- DAL.pdb
- WinFrmPrj.exe
- WinFrmPrj.pdb
- WinFrmPrj.vshost.exe

The contents of the second folder "WinFrmPrj\bin\release" is what gets 
deployed (as I understand), therefore the config file is not available! So 
when I deploy to the target machine I have no config file to edit to target 
the application to the desired database.

#2) How do I have the 'DAL.dll.config' or any editable config file available 
after deployment so that it can be edited

Thank you for your help.

dbuchanan 

4.Add XmlElements to App.config & show changes in Open App.config

I am writing an Add-in in C#.

I would like to add/remove XmlElements from an App.config file (currently 
using the System.Xml classes) and show the changes directly in the open 
App.config file (App.config document should be marked with *) so that:

- VS does not ask to reload the App.config after I wrote changes to the file 
with XmlDocument.Save()
- With Crtl-Z I can undo all the changes
- The App.config file is only saved when the VS user explicitly presses the 
Save button
- When the App.config file is closed during add/removing XmlElements and 
then opened I can see all the changes.

This all works when I change source code with CodeModel. Is there something 
for XML files & VS as well?

Any help really appreciated!!

Thanks, Nils

5.app.dll.config instead of app.exe.config

Hi;

Is there a way for code in my dll to get it's config info from 
MyLibrary.dll.config instead of from TheApp.exe.config?

-- 
thanks - dave

6. Share config between sub web apps

7. Windows Form in Shared Add-in not reading App.config settings

8. How to share an app.config between several applications



Return to VB.NET

 

Who is online

Users browsing this forum: No registered users and 82 guest