System.Windows.Markup.XamlParseException on a Multi Project Solution (Mixed platforms)











up vote
0
down vote

favorite












I've integrated my WPF project into a mixed solution. This solution has 3 projects written in WinForms (.cs), 1 writtenin WinForms (.vb) and the mine one written in WPF (using MahApps).
The Owner of my project/windows must be the one of the three written in WinForm.



I've made a call like this:



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 is my starting point on in the App.xaml



But when I reach the InitializeComponents() of the ProductsMenu.xaml.cs the System.Windows.Markup.XamlParseException were thrown



The error is: IOException: Cannot locate resource 'resources/icons.xaml'.



My App.xaml file:



<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>




I've tried to set the Icons.xaml/Build Action as Resource and also as Page.
I'm missing something?










share|improve this question






















  • Is WPFSolution the name of the assembly that contains Icons.xaml?
    – Clemens
    yesterday










  • Yes, it's the assembly that contains the file. If i run the WPF solution as a standalone module, everything works fine.
    – andrepogg
    yesterday










  • And does the application project reference that assembly?
    – Clemens
    yesterday










  • Yes, I've added the references under: Solution Explorer > MainProject > References > Right Click > Add Reference... > Projects > WPFSolution... Then I checked that the whole solution has the same .NET Framework version (4.6.1)
    – andrepogg
    yesterday

















up vote
0
down vote

favorite












I've integrated my WPF project into a mixed solution. This solution has 3 projects written in WinForms (.cs), 1 writtenin WinForms (.vb) and the mine one written in WPF (using MahApps).
The Owner of my project/windows must be the one of the three written in WinForm.



I've made a call like this:



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 is my starting point on in the App.xaml



But when I reach the InitializeComponents() of the ProductsMenu.xaml.cs the System.Windows.Markup.XamlParseException were thrown



The error is: IOException: Cannot locate resource 'resources/icons.xaml'.



My App.xaml file:



<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>




I've tried to set the Icons.xaml/Build Action as Resource and also as Page.
I'm missing something?










share|improve this question






















  • Is WPFSolution the name of the assembly that contains Icons.xaml?
    – Clemens
    yesterday










  • Yes, it's the assembly that contains the file. If i run the WPF solution as a standalone module, everything works fine.
    – andrepogg
    yesterday










  • And does the application project reference that assembly?
    – Clemens
    yesterday










  • Yes, I've added the references under: Solution Explorer > MainProject > References > Right Click > Add Reference... > Projects > WPFSolution... Then I checked that the whole solution has the same .NET Framework version (4.6.1)
    – andrepogg
    yesterday















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I've integrated my WPF project into a mixed solution. This solution has 3 projects written in WinForms (.cs), 1 writtenin WinForms (.vb) and the mine one written in WPF (using MahApps).
The Owner of my project/windows must be the one of the three written in WinForm.



I've made a call like this:



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 is my starting point on in the App.xaml



But when I reach the InitializeComponents() of the ProductsMenu.xaml.cs the System.Windows.Markup.XamlParseException were thrown



The error is: IOException: Cannot locate resource 'resources/icons.xaml'.



My App.xaml file:



<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>




I've tried to set the Icons.xaml/Build Action as Resource and also as Page.
I'm missing something?










share|improve this question













I've integrated my WPF project into a mixed solution. This solution has 3 projects written in WinForms (.cs), 1 writtenin WinForms (.vb) and the mine one written in WPF (using MahApps).
The Owner of my project/windows must be the one of the three written in WinForm.



I've made a call like this:



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 is my starting point on in the App.xaml



But when I reach the InitializeComponents() of the ProductsMenu.xaml.cs the System.Windows.Markup.XamlParseException were thrown



The error is: IOException: Cannot locate resource 'resources/icons.xaml'.



My App.xaml file:



<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>




I've tried to set the Icons.xaml/Build Action as Resource and also as Page.
I'm missing something?







c# wpf winforms mahapps.metro






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









andrepogg

9710




9710












  • Is WPFSolution the name of the assembly that contains Icons.xaml?
    – Clemens
    yesterday










  • Yes, it's the assembly that contains the file. If i run the WPF solution as a standalone module, everything works fine.
    – andrepogg
    yesterday










  • And does the application project reference that assembly?
    – Clemens
    yesterday










  • Yes, I've added the references under: Solution Explorer > MainProject > References > Right Click > Add Reference... > Projects > WPFSolution... Then I checked that the whole solution has the same .NET Framework version (4.6.1)
    – andrepogg
    yesterday




















  • Is WPFSolution the name of the assembly that contains Icons.xaml?
    – Clemens
    yesterday










  • Yes, it's the assembly that contains the file. If i run the WPF solution as a standalone module, everything works fine.
    – andrepogg
    yesterday










  • And does the application project reference that assembly?
    – Clemens
    yesterday










  • Yes, I've added the references under: Solution Explorer > MainProject > References > Right Click > Add Reference... > Projects > WPFSolution... Then I checked that the whole solution has the same .NET Framework version (4.6.1)
    – andrepogg
    yesterday


















Is WPFSolution the name of the assembly that contains Icons.xaml?
– Clemens
yesterday




Is WPFSolution the name of the assembly that contains Icons.xaml?
– Clemens
yesterday












Yes, it's the assembly that contains the file. If i run the WPF solution as a standalone module, everything works fine.
– andrepogg
yesterday




Yes, it's the assembly that contains the file. If i run the WPF solution as a standalone module, everything works fine.
– andrepogg
yesterday












And does the application project reference that assembly?
– Clemens
yesterday




And does the application project reference that assembly?
– Clemens
yesterday












Yes, I've added the references under: Solution Explorer > MainProject > References > Right Click > Add Reference... > Projects > WPFSolution... Then I checked that the whole solution has the same .NET Framework version (4.6.1)
– andrepogg
yesterday






Yes, I've added the references under: Solution Explorer > MainProject > References > Right Click > Add Reference... > Projects > WPFSolution... Then I checked that the whole solution has the same .NET Framework version (4.6.1)
– andrepogg
yesterday














2 Answers
2






active

oldest

votes

















up vote
0
down vote













Got it (or a workaround at least).




  1. I've dereferenced the WPFSolution Project.

  2. Compiled the WPF solution
    as .dll (I've copied all the merged dictionaries to every
    window.xaml, removed the app.xaml file and change the application
    type to class library)

  3. Copied the WPFSolution.dll in the bin/release
    - bin/debug of the main project

  4. Referenced the .dll


Everything worked like a charm






share|improve this answer




























    up vote
    0
    down vote













    try this syntax :



    <ResourceDictionary Source="/WPFSolution;component/Resources/Icons.xaml" />


    and also, "Page" is the right build option in this case






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














       

      draft saved


      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409112%2fsystem-windows-markup-xamlparseexception-on-a-multi-project-solution-mixed-plat%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      0
      down vote













      Got it (or a workaround at least).




      1. I've dereferenced the WPFSolution Project.

      2. Compiled the WPF solution
        as .dll (I've copied all the merged dictionaries to every
        window.xaml, removed the app.xaml file and change the application
        type to class library)

      3. Copied the WPFSolution.dll in the bin/release
        - bin/debug of the main project

      4. Referenced the .dll


      Everything worked like a charm






      share|improve this answer

























        up vote
        0
        down vote













        Got it (or a workaround at least).




        1. I've dereferenced the WPFSolution Project.

        2. Compiled the WPF solution
          as .dll (I've copied all the merged dictionaries to every
          window.xaml, removed the app.xaml file and change the application
          type to class library)

        3. Copied the WPFSolution.dll in the bin/release
          - bin/debug of the main project

        4. Referenced the .dll


        Everything worked like a charm






        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          Got it (or a workaround at least).




          1. I've dereferenced the WPFSolution Project.

          2. Compiled the WPF solution
            as .dll (I've copied all the merged dictionaries to every
            window.xaml, removed the app.xaml file and change the application
            type to class library)

          3. Copied the WPFSolution.dll in the bin/release
            - bin/debug of the main project

          4. Referenced the .dll


          Everything worked like a charm






          share|improve this answer












          Got it (or a workaround at least).




          1. I've dereferenced the WPFSolution Project.

          2. Compiled the WPF solution
            as .dll (I've copied all the merged dictionaries to every
            window.xaml, removed the app.xaml file and change the application
            type to class library)

          3. Copied the WPFSolution.dll in the bin/release
            - bin/debug of the main project

          4. Referenced the .dll


          Everything worked like a charm







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered yesterday









          andrepogg

          9710




          9710
























              up vote
              0
              down vote













              try this syntax :



              <ResourceDictionary Source="/WPFSolution;component/Resources/Icons.xaml" />


              and also, "Page" is the right build option in this case






              share|improve this answer

























                up vote
                0
                down vote













                try this syntax :



                <ResourceDictionary Source="/WPFSolution;component/Resources/Icons.xaml" />


                and also, "Page" is the right build option in this case






                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  try this syntax :



                  <ResourceDictionary Source="/WPFSolution;component/Resources/Icons.xaml" />


                  and also, "Page" is the right build option in this case






                  share|improve this answer












                  try this syntax :



                  <ResourceDictionary Source="/WPFSolution;component/Resources/Icons.xaml" />


                  and also, "Page" is the right build option in this case







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered yesterday









                  David

                  4,50123247




                  4,50123247






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53409112%2fsystem-windows-markup-xamlparseexception-on-a-multi-project-solution-mixed-plat%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Contact image not getting when fetch all contact list from iPhone by CNContact

                      count number of partitions of a set with n elements into k subsets

                      A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks