开发者

Reuse an existing app config

开发者 https://www.devze.com 2023-03-05 03:21 出处:网络
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.

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.Confi开发者_高级运维guration.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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消