アプリケーション用のプラグインを作成しています (知る必要がある場合は、Autodesk Revit Architecture 2011)。
デバッグ中に、プラグインを再コンパイルしてホストに再ロードしたいと思います。私の特定のホストは、Assembly.Load
. Windows.Forms プラグインの場合、これは魅力的に機能します。
WPFを使用すると、これが壊れます。最初は、次の行に沿ってエラーが発生していました (読みやすくするために書式を追加しました:
System.Windows.Markup.XamlParseException:
[A]MyApp.Controls.MyControl cannot be cast to [B]MyApp.Controls.MyControl.
Type A originates from 'MyApp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location '%PATHA%'.
Type B originates from 'MyApp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location '%PATHB'.
Error at object 'MyApp.Controls.MyControl' in markup file 'MyApp;component/controls/mydialog.xaml'.
また、コントロール、名前空間、およびパスの名前を自由に変更して、罪のない者と犯人である私を保護しました。
これは、XAML パーサーが既に読み込まれた型のキャッシュを保持しているためだと思います。
私の最初のステップは、 を設定して、アセンブリのバージョンを変更することでしたAssemblyInfo.cs/[assembly: AssemblyVersion("2.0.*")
。これはエラーをさらに一歩進めるだけです:
System.Windows.Markup.XamlParseException:
Unable to cast object of type 'MyApp.Controls.MyControl' to type 'MyApp.Controls.MyControl'.
Error at object 'MyApp.Controls.MyControl' in markup file 'MyApp;component/controls/mydialog.xaml'.
---> System.InvalidCastException: Unable to cast object of type 'MyApp.Controls.MyControl' to type 'MyApp.Controls.MyControl'.