2016-03-22 66 views
0

我需要使我的WPF桌面应用程序可用于从WinForms应用程序启动。WPF应用程序:从WinForms应用程序启动时缺少资源

但是,我使用第三方控件(例如来自Telerik),并且只有在将所有相同的引用DLL复制到启动WPF应用程序的WinForms应用程序时才能启动应用程序。

异常始终是无法找到与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

相关问题