Method or operation not implemented error on Binding
Asked Answered
I

2

8

I'm currently developing a Visual Studio plugin (VSPackage) which finally should be able to visualize call relations. In order to represent them I want to use the Graph# library which manages the graph (avoiding overlapping edges etc.). Unfortunately I get the following error message at runtime in my XAML:

XamlParseException: The method or operation is not implemented.

The error pops up on the <graph:CallRelationGraphLayout Graph="{Binding RelationGraph}"/> tag.

<UserControl x:Class="Biocoder.InteractiveExploration.View.ExplorationControl"
         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:graphsharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
         xmlns:zoom="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions"
         xmlns:graph="clr-namespace:Biocoder.InteractiveExploration.Graph"
         xmlns:viewmodels="clr-namespace:Biocoder.InteractiveExploration.ViewModel"
         xmlns:controls="clr-namespace:Biocoder.InteractiveExploration.Controls" mc:Ignorable="d" 
         d:DesignHeight="300" d:DesignWidth="300">



<UserControl.DataContext>
    <viewmodels:ExplorationToolViewModel/>
</UserControl.DataContext>

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <zoom:ZoomControl Grid.Row="1"
                      Zoom="0.2"
                      ZoomBoxOpacity="0.5"
                      Background="Yellow">

        <graph:CallRelationGraphLayout Graph="{Binding RelationGraph}"/>

    </zoom:ZoomControl>

</Grid>

</UserControl>

I also created own vertex, edge and graph layout classes. My graph should finally represent call relations (edges) between methods (vertices).

MethodVertex.cs

public class MethodVertex
{
    public string ID { get; private set; }
    public bool IsMale { get; private set; }

    public MethodVertex(string id, bool isMale)
    {
        ID = id;
        IsMale = isMale;
    }

    public override string ToString()
    {
        return string.Format("{0}-{1}", ID, IsMale);
    }
}

RelationEdge.cs

public class RelationEdge : Edge<MethodVertex>
{
    public string Id { get; private set; }

    public RelationEdge(string id, MethodVertex source, MethodVertex target)
        : base(source, target)
    {
        Id = id;
    }
}

CallRelationGraphLayout.cs

public class CallRelationGraphLayout : GraphLayout<MethodVertex, RelationEdge, CallRelationGraph>
{}

CallRelationGraph.cs

public class CallRelationGraph : BidirectionalGraph<MethodVertex, RelationEdge>
{
    public CallRelationGraph()
    {}

    public CallRelationGraph(bool allowParallelEdges)
        : base(allowParallelEdges)
    { }

    public CallRelationGraph(bool allowParallelEdges, int vertexCapacity)
        : base(allowParallelEdges, vertexCapacity)
    {}
}

In the ExplorationToolViewModel I declared the RelationGraph as follows:

private CallRelationGraph _relationGraph;
public CallRelationGraph RelationGraph
{
    get { return _relationGraph; }
    set
    {
        if (value != _relationGraph)
        {
            _relationGraph = value;
            NotifyPropertyChanged("RelationGraph");
        }
    }
}

public event PropertyChangedEventHandler PropertyChanged;

public void NotifyPropertyChanged(string propertyName)
{
    if (PropertyChanged != null)
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}

What I maybe also should mention is that I have the following error displayed sometimes but the project compiles and runs.

GenericArguments[1 ], 'Biocoder.InteractiveExploration.Graph.RelationEdge', on 'GraphSharp.Algorithms.Layout.ILayoutAlgorithm`3[TVertex,TEdge,TGraph]' violates the constraint of type 'TEdge'.

Maybe its the source of the problem but I ignored it so far since it compiled and I did it corresponding to this tutorial.

The strange thing is that it actually works in a normal WPF application using the DLLs provided by Graph#. When I leave the Graph-property out the error doesn't show up so I guess it has to do with the Graph property. Any hints about how to solve this?

Thank you very much in advance!

Itching answered 22/10, 2012 at 7:56 Comment(2)
@Palesz Thanks Palesz! I just added my vertex, edge and layout classes. Basically I did everything as shown in Sacha Baber's blog.Itching
NotImplementedException sure doesn't help much! I've written up a guide on how to diagnose the underlying problem at https://mcmap.net/q/1010542/-notimplementedexception-when-loading-xaml-via-system-windows-application-loadcomponent.Deflocculate
U
2

I've experienced the same issue when using Graph# in a VSPackage. I was able to overcome the issue by not using Bindings for the graph, but by assigning the Graph property in CodeBehind.

This led to an exception that the WPFExtensions assembly could not be loaded when assigning the Graph property. I suspect that the reason for that is that in GraphSharp.Controls, the assembly is used in XAML, but the reference is not added when compiling as there are no references in code. I was able to fix this by adding the following line before assigning the Graph property:

var a = System.Reflection.Assembly.Load("WPFExtensions, Version=1.0.3437.34043, Culture=neutral, PublicKeyToken=null");

This line loads the WPFExtensions library before WPF tries to load it based on the reference in the XAML. Afterwards, the graph was shown.

Unstained answered 14/2, 2014 at 16:59 Comment(1)
This worked for me! Simply adding the System.Reflection.Assembly.Load("RequiredLibrary, Version={VersionNumber}, Culture=neutral, PublicKeyToken=null"); in the constructor of a XAML page before the InitializeComponent(); line did the trick. Thank you!Serviceable
C
1

In my case an assembly wasn't copied to the output folder because copy local was set to false. Setting copy local to true solved it. (An assembly A was dependent on assembly B which didn't have the copy local flag.)

Clavius answered 30/11, 2017 at 12:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.