關於某些 .Net 程式無法啟動的問題

來源:互聯網
上載者:User

  幾天前,我的 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 到底是哪個程式刪的,我發誓,我絕對沒碰過它。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.