2016-03-22 9 views
0

WinFormsアプリケーションから起動するためにWPF Desktopアプリケーションを使用できるようにする必要があります。WPFアプリケーション:WinForms Appから起動するとリソースが見つかりません

ただし、私はTelerikなどのサードパーティコントロールを使用していますが、WPFアプリケーションを起動しているWinFormsアプリケーションに同じ参照DLLをすべてコピーすると、アプリケーションを起動することができます。

例外は、常にapplication.xamlに関連付けられたファイルまたは依存ファイルが見つからないことです。おそらく実行アセンブリのためです。

WPFアプリケーションを起動するWinFormsアプリケーションへの参照を追加することは許可されていません。そのため、WPFアプリケーションを適切な場所に配置するにはどうすればよいですか?

これは、問題が発生したことを私のメインウィンドウのリソースセクションでここにもあります:

<Application x:Class="Application" 
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      StartupUri="MainWindow.xaml"> 
<Application.Resources> 
    <ResourceDictionary> 
     <ResourceDictionary.MergedDictionaries> 
      <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/System.Windows.xaml" /> 
      <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.xaml" /> 
      <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Input.xaml" /> 
      <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Data.xaml" /> 
      <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Navigation.xaml" /> 
      <ResourceDictionary Source="/Telerik.Windows.Themes.Expression_Dark;component/Themes/Telerik.Windows.Controls.Docking.xaml" /> 
     </ResourceDictionary.MergedDictionaries> 
    </ResourceDictionary> 
</Application.Resources> 

感謝します。

答えて

1

WinFormsのアプリケーションディレクトリに、アプリケーションが見つかったときにエラーがスローされ、アプリケーションのディレクトリにある依存するアセンブリをアプリケーションが探していると思います。この場合、AssemblyResolveイベントを見て、アセンブリの正しい場所を指すことができます。

+0

すぐにお返事ありがとうございます。これは間違いなく知っておくと便利ですが、この場合WPFアプリケーションはCOMクラスを介して起動されている可能性がありますので、私はこれを自由に使用できません。 WPFアプリケーションのコンストラクターでこれを強制したり、可能であればxamlに直接指定したりします。 – miriyo

関連する問題