惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客

博客园 - 楚潇

有关sqlserver的锁 基于dotnet2.0的联通sgip1.2协议二级网关源码 .net winform下TreeNode在没有子结点时也显示+号的解决办法 在vs2005中用gridview显示表中的image字段 - 楚潇 - 博客园 谁没在变! vs2k5 中asp.net "Web Site Administration Tool "使用中遇到的问题 - 楚潇 美达飞凡16X DVD起死回生记 寄语八十年代的新一代 小胜凭智, 大胜靠德 《windows核心编程》 再读<心航> C#中判断socket是否已断开的方法 将对象转为byte[] 摘自古龙的句子 端午节到了 C#中的字符串格式化 .net开发手机短信 怎样才能提高.net的水平呢? Reflaction很嚣张的功能
visual C# 2005 express beta2读配置文件的问题(ms的bug?)
楚潇 · 2005-08-01 · via 博客园 - 楚潇

visual C# 2005 express beta2读配置文件的问题:

app.config
-----------------------------------------------------------------------------------

<?xml version="1.0" encoding="utf-8" ?>

<configuration>
 
<configSections>
  
<sectionGroup name="mySectionGroup">
   
<section name="mySection"
      type
="System.Configuration.DictionarySectionHandler" />
  
</sectionGroup>
 
</configSections>
 
<mySectionGroup>
  
<mySection>
   
<add key="key1" value="value1" />
  
</mySection>
 
</mySectionGroup>
</configuration>

读取配置文件的程序(在项目中需要手动添加System.configuration的引用):

using System;
using System.Collections.Generic;
using System.Text;

using System.Collections.Specialized;
using System.Configuration;

namespace ConsoleApplication2
{
    
class Program
    
{
        
static void Main(string[] args)
        
{
            
try
            
{
                NameValueCollection ns 
= (NameValueCollection)ConfigurationManager.GetSection("mySectionGroup/mySection");
                
string s = ns["key1"];
                
int n = Convert.ToInt32(ns["key2"]);
                Console.WriteLine(s 
+ "" + n.ToString());
            }

            
finally
            
{
                Console.Read();
            }

        }

    }

}


结果执行老是出现异常,在vs2k3里这样的代码运行都很正常的!
请问:在2005中该怎么样读取配置文件中的信息?