A
Anders Eriksson
I have an application, DCMarker.exe, that uses app.config for some
configuration. I have created a class, Config.cs, that contains all the
configuration and I have this method to get the values out of app.config
private void InitConfig()
{
this.imagePath = Properties.Settings.Default.imagePath;
this.jobfilePath = Properties.Settings.Default.jobfilePath;
this.templatePath = Properties.Settings.Default.templatePath;
this.projectPath = Properties.Settings.Default.projectPath;
this.axisXEnable = Properties.Settings.Default.axisXEnable;
this.axisYEnable = Properties.Settings.Default.axisYEnable;
this.axisZEnable = Properties.Settings.Default.axisZEnable;
this.axisREnable = Properties.Settings.Default.axisREnable;
}
This works!
Now I want to use the same configuration in a dll that the application uses.
The application has namespace: DCMarker
and the dll has namespace: DCMarkerLib
The app.config is created using the Settings tab in the Properties for
the application. See below for xml code.
How should I do this so that I can use the same app.config file in both
the exe and the dll?
// Anders
--
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DCMarker.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DCMarker.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<DCMarker.Properties.Settings>
<setting name="test" serializeAs="String">
<value>Hello world!</value>
</setting>
</DCMarker.Properties.Settings>
</userSettings>
<applicationSettings>
<DCMarker.Properties.Settings>
<setting name="jobfilePath" serializeAs="String">
<value>C:\jobfiles\</value>
</setting>
<setting name="imagePath" serializeAs="String">
<value>c:\bilder\</value>
</setting>
<setting name="templatePath" serializeAs="String">
<value>c:\bilder\</value>
</setting>
<setting name="projectPath" serializeAs="String">
<value>c:\prj\</value>
</setting>
<setting name="axisXEnable" serializeAs="String">
<value>0</value>
</setting>
<setting name="axisYEnable" serializeAs="String">
<value>0</value>
</setting>
<setting name="axisZEnable" serializeAs="String">
<value>0</value>
</setting>
<setting name="axisREnable" serializeAs="String">
<value>0</value>
</setting>
</DCMarker.Properties.Settings>
</applicationSettings>
</configuration>
configuration. I have created a class, Config.cs, that contains all the
configuration and I have this method to get the values out of app.config
private void InitConfig()
{
this.imagePath = Properties.Settings.Default.imagePath;
this.jobfilePath = Properties.Settings.Default.jobfilePath;
this.templatePath = Properties.Settings.Default.templatePath;
this.projectPath = Properties.Settings.Default.projectPath;
this.axisXEnable = Properties.Settings.Default.axisXEnable;
this.axisYEnable = Properties.Settings.Default.axisYEnable;
this.axisZEnable = Properties.Settings.Default.axisZEnable;
this.axisREnable = Properties.Settings.Default.axisREnable;
}
This works!
Now I want to use the same configuration in a dll that the application uses.
The application has namespace: DCMarker
and the dll has namespace: DCMarkerLib
The app.config is created using the Settings tab in the Properties for
the application. See below for xml code.
How should I do this so that I can use the same app.config file in both
the exe and the dll?
// Anders
--
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DCMarker.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DCMarker.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<DCMarker.Properties.Settings>
<setting name="test" serializeAs="String">
<value>Hello world!</value>
</setting>
</DCMarker.Properties.Settings>
</userSettings>
<applicationSettings>
<DCMarker.Properties.Settings>
<setting name="jobfilePath" serializeAs="String">
<value>C:\jobfiles\</value>
</setting>
<setting name="imagePath" serializeAs="String">
<value>c:\bilder\</value>
</setting>
<setting name="templatePath" serializeAs="String">
<value>c:\bilder\</value>
</setting>
<setting name="projectPath" serializeAs="String">
<value>c:\prj\</value>
</setting>
<setting name="axisXEnable" serializeAs="String">
<value>0</value>
</setting>
<setting name="axisYEnable" serializeAs="String">
<value>0</value>
</setting>
<setting name="axisZEnable" serializeAs="String">
<value>0</value>
</setting>
<setting name="axisREnable" serializeAs="String">
<value>0</value>
</setting>
</DCMarker.Properties.Settings>
</applicationSettings>
</configuration>