几天前,我的 Live Writer 不能使用了,每次显示 Splash Screen 就显示错误报告,说未捕获的 NullReferenceException,使用 VS2005 调试也看不出什么东西。当时估计可能是什么本地配置出问题。因为我把 Live Writer Copy 到 VMWare 中的系统是可以正常使用的。无果,只好在虚拟机中使用 Live Writer,真够重量级。

  然后在今天想使用 NetMassDownloader 下载 .Net 源代码,结果依然是在启动后抛出异常:

未处理的异常:  System.Configuration.ConfigurationErrorsException: 配置节“connectionStrings”具有意外的声明。
   在 System.Configuration.ConfigurationManager.get_ConnectionStrings()
   在 System.Configuration.PrivilegedConfigurationManager.get_ConnectionStrings()
   在 System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties)
   在 System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider)
   在 System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)
   在 System.Configuration.SettingsBase.get_Item(String propertyName)
   在 System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName)
   在 System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)

   在 DownloadLibrary.Properties.Settings.get_EULACookie() 位置 C:\Documents and Settings\Kusmezer\My Documents\Visual Studio 2005\Projects\Project1\DownloadLibrary\Properties\Settings.Designer.cs:行号 31
   在 DownloadLibrary.Classes.Utility.GetWebClientWithCookie(Match ProxyMatch)位置 C:\Documents and Settings\Kusmezer\My Documents\Visual Studio 2005\Projects\Project1\DownloadLibrary\Classes\Utility.cs:行号 142
   在 DownloadLibrary.PEParsing.PEFile.DownloadPDBFromServer(String targetPath)位置 C:\Documents and Settings\Kusmezer\My Documents\Visual Studio 2005\Projects\Project1\DownloadLibrary\Classes\PEFile\PEFile.cs:行号 142
   在 NetMassDownloader.Program.ProcessFiles() 位置 C:\Documents and Settings\Kusmezer\My Documents\Visual Studio 2005\Projects\Project1\NetMassDownloader\Program.cs:行号 148
   在 NetMassDownloader.Program.Main(String[] args) 位置 C:\Documents and Settings\Kusmezer\My Documents\Visual Studio 2005\Projects\Project1\NetMassDownloader\Program.cs:行号 78

  这次有异常调用栈信息就好说了嘛,可以判断是读取配置文件的问题,但是NetMassDownloader 应该不需要connectionStrings,可能是本机配置的问题。

  于是祭出 Sysinternal FileMon,看下启动时读取过哪些文件,经过详细排查,发现读取数个配置文件失败后调用了 DW20.exe,这些配置文件包括 {NetFx20}\config\machine.config,{AppData}\user.config,{UserData}\user.config。

  打开"{NetFx20}\config\" 目录一看,靠,machine.config 不见了!只有一个 machine.default,Copy 成 machine.config,启动 Live Writer 和 NetMassDownloader,正常 =_=|||。

  这里记住一个经验,.Net Runtime 是非常依赖配置文件的,如果你发现你的程序出了些莫名其妙的问题,看看,machine.config 还在不在配置目录吧。

  PS:我现在依然不明白,machine.config 到底是哪个程序删的,我发誓,我绝对没碰过它。

posted on 2008-02-23 12:13  Zealic  阅读(3393)  评论(1编辑  收藏  举报