0

InitializeComponent exception

Robert 10 months ago • updated 10 months ago 3

I get an exception whenever I try to use OxyPlot in a UserControl (VS extension), I see that OxyPlot.dll and OxyPlot.Wpf.dll exist in the deployment location, and the XAML parses fine in the designer.


XAML:
<usercontrol x:class="GraphicalDebugging.PlotWatchControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf" 
             mc:ignorable="d"
             d:designheight="300" d:designwidth="800">
  <grid>
    <oxy:plotview model="{Binding MyModel}"></oxy:plotview>
  </grid>
</usercontrol>

and in my UserControl class I got:

using OxyPlot;
using OxyPlot.Wpf;
namespace MyNS {
    public partial class MyControl : Usercontrol
    {
        ...
        public PlotModel MyModel { get; private set; }
    }
} 


The exception I get is:

System.Windows.Markup.XamlParseException occurred
  HResult=0x80131501
  Message=Could not load file or assembly 'OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0' or one of its dependencies. The system cannot find the file specified.
  Source=PresentationFramework
  StackTrace:
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at GraphicalDebugging.PlotWatchControl.InitializeComponent() in C:\code\git\temp\graphical-debugging\Visual_Studio_2015\GraphicalDebugging\PlotWatchControl.xaml:line 1
   at GraphicalDebugging.PlotWatchControl..ctor() in C:\code\git\temp\graphical-debugging\Visual_Studio_2015\GraphicalDebugging\PlotWatchControl.xaml.cs:line 29
   at GraphicalDebugging.PlotWatch..ctor() in C:\code\git\temp\graphical-debugging\Visual_Studio_2015\GraphicalDebugging\PlotWatch.cs:line 37
Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'OxyPlot.Wpf, PublicKeyToken=75e952ba404cdbb0' or one of its dependencies. The system cannot find the file specified.

I've installed OxyPlot.Wpf via Nuget. Ideas ??

Added OxyPlot.dll and OxyPlot.Wpf.Dll with gacutil, problem remains.

Oh, btw, I'm using VS2017 for development, and VS2015 for debugging it...


Had to resort to assembly resolving through AppDomain.CurrentDomain.AssemblyResolve event.