バックグラウンド スレッドで幾何学的解析を行っているプログラムがあります。
通常、これは非常にうまく機能しますが、驚くべきことに、開発用コンピューターで PathGeometry を作成しようとすると例外が発生します。
簡単なコードでは次のようになります。
PathGeometry geometry = new PathGeometry();
System.TypeInitializationException {"Der Typeninitialisierer für \"System.Windows.Media.PathGeometry\" hat eine Ausnahme verursacht."}
スタック トレースは次のとおりです。
bei System.Windows.Media.PathGeometry..ctor()
bei Bsoft.ilka.AlkisLeser.AlkisDatei.GetPosition(XElement xe) in AlkisDatei.cs:Zeile 267.
この例外には InnerException が含まれます System.ComponentModel.Win32Exception {"Ungültiges Fensterhandle"} InnerException のスタック トレースは次のとおりです。
bei MS.Win32.UnsafeNativeMethods.GetWindowLongWndProc(HandleRef hWnd)
bei MS.Win32.HwndSubclass.UnhookWindowProc(Boolean force)
bei MS.Win32.HwndSubclass.Dispose()
bei MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
bei System.Windows.Threading.Dispatcher..ctor()
bei System.Windows.Threading.Dispatcher.get_CurrentDispatcher()
bei System.Windows.DependencyObject..ctor()
bei System.Windows.Media.PathFigureCollection.get_Empty()
bei System.Windows.Media.PathGeometry..cctor()
奇妙なことに、実行可能ファイルは他のコンピューターでも動作します。
何が問題ですか?PathGeometry コンストラクターがウィンドウ ハンドルにアクセスしようとするのはなぜですか? これを解決するにはどうすればよいですか?
私は .NET Framework 4.0 を使用しており、VS2010 と VS2012 の両方でコードがスローされます。