首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >多项目解决方案(混合平台)上的System.Windows.Markup.XamlParseException

多项目解决方案(混合平台)上的System.Windows.Markup.XamlParseException
EN

Stack Overflow用户
提问于 2018-11-21 09:40:14
回答 1查看 213关注 0票数 0

我已经将我的WPF项目集成到一个混合解决方案中。该解决方案有3个用WinForms (.cs)编写的项目,1个写WinForms (.vb)项目和一个用WPF编写的项目(使用MahApps)。我的项目/窗口的所有者必须是用WinForm编写的三个中的一个。

我打过这样的电话:

代码语言:javascript
复制
using WPFSolution;
using System.Windows.Forms.Integration;

private void buttonOpenWPFUi_Click(object sender, EventArgs e)
    {
        var pm = new ProductsMenu();
        ElementHost.EnableModelessKeyboardInterop(pm);
        pm.Show();
    }

ProductsMenu是我在App.xaml中的起点

但是当我到达System.Windows.Markup.XamlParseExceptionInitializeComponents() of ProductsMenu.xaml.cs

错误是:IOException:无法定位资源'resources/icons.xaml'.

我的App.xaml文件:

代码语言:javascript
复制
<Application x:Class="WPFSolution.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         StartupUri="ProductsMenu.xaml" ShutdownMode="OnMainWindowClose">
<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedTabControl.xaml" />
            <!-- Accent and AppTheme setting -->
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Red.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
            <!-- BaseDark.xaml | BaseLight.xaml -->
            <!-- Icons -->
            <ResourceDictionary Source="pack://application:,,,/WPFSolution;component/Resources/Icons.xaml"></ResourceDictionary>

            <!-- Languages -->
            <!--<ResourceDictionary Source="Resources/StringResources.en.xaml"></ResourceDictionary>-->
            <ResourceDictionary Source="Resources/StringResources.it.xaml"></ResourceDictionary>

        </ResourceDictionary.MergedDictionaries>

        <Style TargetType="{x:Type ToolTip}">
            <Setter Property="Background" Value="White"/>
            <Setter Property="BorderBrush" Value="Red"/>
            <Setter Property="BorderThickness" Value="2"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="Padding" Value="7,4,7,4"/>
        </Style>


        <!--IMMAGINI -->
        <!--nodi-->
        <!--<BitmapImage x:Key="Nodo1" UriSource="Resources/img/TileImages/nodi/nodo1.jpg"></BitmapImage>
        <BitmapImage x:Key="Nodo2" UriSource="Resources/img/TileImages/nodi/nodo2.jpg"></BitmapImage>
        <BitmapImage x:Key="Nodo3" UriSource="Resources/img/TileImages/nodi/nodo3.jpg"></BitmapImage>
        <BitmapImage x:Key="Nodo4" UriSource="Resources/img/TileImages/nodi/nodo4.jpg"></BitmapImage>-->


    </ResourceDictionary>
</Application.Resources>

我尝试将Icons.xaml/Build设置为Resource和Page。我漏掉了什么?

EN

Stack Overflow用户

发布于 2018-11-21 13:34:16

明白了(或者至少有个解决办法)。

  1. 我取消了WPFSolution项目的引用。
  2. 将WPF解决方案编译为.dll (我已将所有合并字典复制到每个window.xaml,删除了app.xaml文件并将应用程序类型更改为类库)
  3. 在主项目的bin/release /调试中复制WPFSolution.dll
  4. 引用.dll

每件事都很有魅力

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53409112

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档