创建并加载一个单独的Application.Config文件 [英] Create and load a separate Application.Config file

查看:50
本文介绍了创建并加载一个单独的Application.Config文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个解决方案,其中包含两个以上的应用程序,包括asp.net网站和控制台应用程序.两个应用程序都使用相同的连接字符串和一些公用值.我想创建一个单独的配置文件以读取这些值,并且该配置文件将放置在系统中的任何位置.我需要创建另一个实用程序来读取该配置文件,并通过该实用程序获取值并在两个应用程序中使用.

Hi, I have a solution which contains more than 2 application including an asp.net website and console application. Both of the application using the same connection string and some common values. I want to create a separate config file to read those values and that config file will be placed anywhere in the system. I need to created a another utility to read that config file and fetch the values through that utility and use in both the application. Is there any method to achieve this?

推荐答案

你好,

如果两个应用程序的ConnectionString仅遇到问题,则可以在一个配置文件中定义多个connectionString.我认为您不需要同时使用多个配置文件.

请参考 http://msdn.microsoft.com/en-us/library/ms254494.aspx [ ^ ]

例如:
Hello,

If you are facing only problem with ConnectionString for both application so you can define more than one connectionString in one config file. I don''t think that you need to use more than one config file for both.

Please refer this http://msdn.microsoft.com/en-us/library/ms254494.aspx[^]

example:
<connectionStrings>
    <add name="connection1" connectionString="user id=user;password=123;server=10.0.0.1;database=myDatabase;connection timeout=30"/>
    <add name="connection2" connectionString="user id=user;password=123;server=10.0.0.2;database=myDatabase;connection timeout=30"/>
</connectionStrings>


这篇关于创建并加载一个单独的Application.Config文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆