Click here to Skip to main content
15,920,438 members
Home / Discussions / C#
   

C#

 
GeneralRe: app.config Pin
fmardani13-Dec-05 4:31
fmardani13-Dec-05 4:31 
GeneralRe: app.config Pin
Curtis Schlak.13-Dec-05 4:42
Curtis Schlak.13-Dec-05 4:42 
GeneralRe: app.config Pin
fmardani13-Dec-05 4:47
fmardani13-Dec-05 4:47 
GeneralRe: app.config Pin
Curtis Schlak.13-Dec-05 4:52
Curtis Schlak.13-Dec-05 4:52 
GeneralRe: app.config Pin
fmardani13-Dec-05 4:53
fmardani13-Dec-05 4:53 
GeneralRe: app.config Pin
Curtis Schlak.13-Dec-05 4:59
Curtis Schlak.13-Dec-05 4:59 
GeneralRe: app.config Pin
fmardani13-Dec-05 5:01
fmardani13-Dec-05 5:01 
GeneralRe: app.config Pin
Curtis Schlak.13-Dec-05 5:27
Curtis Schlak.13-Dec-05 5:27 
If I understand this correctly, you have the following:

Client Application: Windows Forms Application
Data Layer Library: Class Library

If you use the classes from the Data Layer Application in the Client Application, then you can use the .config file distributed with the Client Application. For example, your Client Application's executable is aCoolClientApp.exe. You have a .config file distributed with it named aCoolClientApp.exe.config. Your Data Layer Library will read its appSettings from aCoolClientApp.exe.config.

For example, I have an Windows Forms solution named WindowsApplication4 and a Class Library named ClassLibrary1. They contain the following, respectively:
// In WindowsApplication4
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;

namespace WindowsApplication4
{
  public class Form1 : System.Windows.Forms.Form
  {
    public Form1()
    {
      DataLayer.Data data = new DataLayer.Data();
      Text = data.GetMySetting();
    }
    
    protected override void Dispose( bool disposing )
    {
      base.Dispose( disposing );
    }

    [STAThread]
    static void Main() 
    {
      Application.Run(new Form1());
    }
}
// In ClasLibrary1
using System;

namespace DataLayer
{
  public class Data
  {
    public Data() {}

    public string GetMySetting()
    {
      return System.Configuration.ConfigurationSettings.AppSettings[ "MySetting" ];
    }
  }
}

And, finally, I create the WindowsApplication4.exe.config file with the following contents.
<configuration>
   <appSettings>      
      <add key="MySetting" value="I love C#" />
   </appSettings>
</configuration>
Now, the call in DataLayer.Data.GetMySetting() will read the setting in WindowsApplication4.exe.config and return it.

Does that help?

"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
GeneralRe: app.config Pin
fmardani13-Dec-05 5:32
fmardani13-Dec-05 5:32 
GeneralRe: app.config Pin
Curtis Schlak.13-Dec-05 5:36
Curtis Schlak.13-Dec-05 5:36 
GeneralRe: app.config Pin
fmardani13-Dec-05 5:37
fmardani13-Dec-05 5:37 
GeneralRe: app.config Pin
Curtis Schlak.13-Dec-05 5:40
Curtis Schlak.13-Dec-05 5:40 
GeneralRe: app.config Pin
fmardani13-Dec-05 5:57
fmardani13-Dec-05 5:57 
GeneralRe: app.config Pin
Curtis Schlak.13-Dec-05 6:08
Curtis Schlak.13-Dec-05 6:08 
GeneralRe: app.config Pin
fmardani13-Dec-05 6:22
fmardani13-Dec-05 6:22 
GeneralRe: app.config Pin
Curtis Schlak.13-Dec-05 6:32
Curtis Schlak.13-Dec-05 6:32 
QuestionProblem with deserialization Pin
Wjousts13-Dec-05 4:06
Wjousts13-Dec-05 4:06 
AnswerRe: Problem with deserialization Pin
Robert Rohde13-Dec-05 4:51
Robert Rohde13-Dec-05 4:51 
GeneralRe: Problem with deserialization Pin
Wjousts14-Dec-05 2:52
Wjousts14-Dec-05 2:52 
QuestionHow to get message from Queue? Pin
Rashid.Mahmood13-Dec-05 3:55
Rashid.Mahmood13-Dec-05 3:55 
QuestionC# and VTAPI ACTIVE X CONTROL Pin
CRASH7213-Dec-05 3:52
CRASH7213-Dec-05 3:52 
QuestionTest for Network Connection Pin
dbrenth13-Dec-05 3:47
dbrenth13-Dec-05 3:47 
AnswerRe: Test for Network Connection Pin
pitnu13-Dec-05 4:09
pitnu13-Dec-05 4:09 
AnswerRe: Test for Network Connection Pin
MarcelErz13-Dec-05 4:41
MarcelErz13-Dec-05 4:41 
GeneralRe: Test for Network Connection Pin
MarcelErz13-Dec-05 4:45
MarcelErz13-Dec-05 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.