一个Visual Studio2010的bug….
2011-12-23 11:36
337 查看
今天发现一个VisualStudio2010的bug。是这样的,VS中Project属性有一项是关于Hosting Process的,如果我关闭这个选项,bug就出来了….
大家知道,.NET程序有个App.config/web.config,我现在把它重定向到另外一个位置的配置文件:
[/code]
这样重定向以后你用
[/code]
[/code]
[/code]
PS: 不知道哪位大侠遇到过,似乎MSDN上有关Visual Studio Hosting Process的信息很少很少。
大家知道,.NET程序有个App.config/web.config,我现在把它重定向到另外一个位置的配置文件:
[code] AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", newCfgFile);
[/code]
这样重定向以后你用
ConfigurationManager就会发现它会自动读取重定向的配置文件了。
为了演示,建立一个简单的WindowForms程序,代码:
[code] private void Form1_Load(object sender, EventArgs e)
{
string newCfgFile = @"C:\2.cfg";
AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", newCfgFile);
this.textBox1.Text = ConfigurationManager.ConnectionStrings["SqlServices"].ConnectionString;
}
[/code]
程序App.config内容如下:
[code] <?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="SqlServices" providerName="System.Data.SqlClient" connectionString="Persist Security Info=True;timeout=5;Data Source=127.0.0.1;Initial Catalog=abc;User ID=;Password="/>
</connectionStrings>
</configuration>
[/code]
2.cfg内容(重定向的):
[code] <?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="SqlServices" providerName="System.Data.SqlClient" connectionString="Persist Security Info=True;timeout=5;Data Source=127.0.0.2;Initial Catalog=abc;User ID=;Password="/>
</connectionStrings>
</configuration>
[/code]
注意在debug模式下在VS2010中运行,如果我关闭”Enable Visual Studio Hosting Process”选项的话,取得的值就不对了。虽然重定向成功,但似乎ConfigurationManager还是读取老的配置文件。(如果不是在debug模式下在VS2010中运行,而是直接运行可执行文件*.exe,那就没有问题,所以可以断定是VS2010 debugger 的问题。)
PS: 不知道哪位大侠遇到过,似乎MSDN上有关Visual Studio Hosting Process的信息很少很少。
相关文章推荐
- delphi2007 很大的一个bug
- QQ的一个BUG
- VC6 DEBUG版下内存控制的一个BUG,导致debug版程序必将崩溃
- OSChina 周三乱弹 —— 一个BUG扣多少工资
- NOKIA手机无法发短信息的一个小Bug。
- IntelliJ IDEA Community版独特的一个bug:某些目录下的文件能显示但不被编译
- 发现了cntk 2.0 rnn方面的一个bug
- 提交了 VS 2008 sp1 对 Linq to SQL 的 xml 字段类型支持的一个 bug
- ORA-01791: not a SELECTed expression 一个不是 bug 的 bug!
- 一个分号引起的bug
- 发现 ASP.Net 的一个关于"回车提交"的 Bug ? 必须多于一个 Text 域"回车提交",Server: ButtonX_Click 才能截获!
- 关于Ext.form.NumberField中输入一个超大数字,失去焦点后变成另一个数字的bug的处理
- Qt的一个bug
- boost编译的一个bug:undefined reference to `boost::system::generic_category()'
- 用递归算法解决VC中CEdit的一个Bug
- 一个panic bug的分析过程(一)
- 昨晚碰到的一个bug
- 一个诡异BUG引发的血案(线程死锁造成的CPU利用率逐渐增高)
- 发现一个小BUG
- 导入时遇到一个BUG?