yonan2236
yonan2236

Reputation: 13649

Reuse an existing app config

How I can reuse an app config of an existing application? Given that the app config is located in a common repository of a network accessible for all.

I found this snippet:

System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(strConfigPath); //Path to your config file
    System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap);

But I got this error in my application, I am using .Net 2.0

The type or namespace name 'ConfigurationFileMap' does not exist in the namespace 'System.Configuration' (are you missing an assembly reference?) The type or namespace name 'Configuration' does not exist in the namespace 'System.Configuration' (are you missing an assembly reference?)

How should I do this?

Upvotes: 4

Views: 827

Answers (1)

Polity
Polity

Reputation: 15130

App.config by default is embedded in your assembly. One option i would recommend is to add your shared app.config as a linked item, Project -> Add Existing Item -> \Shared\App.Config -> (Small arrow next to add) -> Add as link

This basicly makes a shortcut to the actual file

Upvotes: 2

Related Questions