FileSystemWatcher丟出TargetInvocationException

  • 2516
  • 0

最近要使用到FileSystemWatcher物件,發現丟出這樣的Exception,查MSDN也不知道是怎麼回事.

但遇到的時候不要去查TargetInvocationException,那解決不了問題.

最近要使用到FileSystemWatcher物件,發現丟出這樣的Exception,查MSDN也不知道是怎麼回事.

結果step in進去看,發現根本不是TargetInvocationException,而是不管怎樣的Exception,

只要在FileSystemWatcher的Event Handler裡發生,都會變成TargetInvocationException.

不知道為甚麼要這樣設計,但遇到的時候不要去查TargetInvocationException,那解決不了問題.

My WP Blog with english technical docs.