我一直在駕駛自己的堅果試圖找出今天這一個。我一直在使用FileSystemWatcher一段時間來捕獲文件更改。我最初在framework 3.5上的一個項目被移動到4.0,以利用一些EF的東西,這似乎影響了Visual Studio如何讓我調試利用FileSystemWatcher的代碼。下面是我遇到的問題的一個小例子(見watcher_Changed):FileSystemWatcher阻止調試器捕獲異常
class Program
{
static void Main(string[] args)
{
FileSystemWatcher watcher = new FileSystemWatcher(@"C:\inputFolder\");
watcher.Changed += new FileSystemEventHandler(watcher_Changed);
watcher.NotifyFilter = NotifyFilters.LastAccess
| NotifyFilters.LastWrite
| NotifyFilters.FileName
| NotifyFilters.DirectoryName;
Console.WriteLine("Ready");
watcher.EnableRaisingEvents = true;
Thread.Sleep(System.Threading.Timeout.Infinite);
}
static void watcher_Changed(object sender, FileSystemEventArgs e)
{
//This exception here (just an example), does not get sent to the debugger, rather it goes to the
//console and then the application exits
throw new ArgumentException();
}
}
代碼將始終貼近我折騰的ArgumentException到控制檯後。這在更復雜的場景中對我造成了一些主要的調試問題。
任何想法?
謝謝,我認爲幫助!我能夠通過兩種方式解決它:1)從調試器設置中刪除'只是我的代碼'設置2)檢查調試 - >異常下的所有拋出的項目 – yabbi