VSPackage 프로젝트에서 Graph# 라이브러리를 사용하려고하지만 불행히도 정복하기에 몇 가지 어려움이 있습니다.그래프 # 라이브러리를 사용할 때 XamlParseException
내가 프로젝트 루트에있는 모든 DLL의 폴더로는 다음과 같은/라이브러리 복사 : 여기에 내가 무슨 짓을
- GraphSharp.dll을
- QuickGraph.dll
- WPFExtensions.dll
모두의 빌드 작업은 '콘텐츠'를 출력하는 옵션 복사 '를 복사하지 않음'으로 설정되어 있습니다.
내 프로젝트에 이러한 참조를 추가했습니다. (참조 추가 -> 찾아보기 -> 라이브러리 폴더에서 선택)
그 다음에 다음 파일을 생성했습니다. ViewModel은 UserControl의 DataContext로 설정되고 UI가 바인딩되는 "MethodGraph"를 정의한다는 것을 알 수 있습니다.
XAML 파일
<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"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListView Grid.Row="0" ItemsSource="{Binding SelectedMethods}">
<ListView.View>
<GridView>
<GridViewColumn Header="Method" DisplayMemberBinding="{Binding Name}"/>
<GridViewColumn Header="ReturnType" DisplayMemberBinding="{Binding ReflectionInfo.ReturnType}"/>
<GridViewColumn Header="Incoming Calls"/>
<GridViewColumn Header="Outgoing Calls"/>
</GridView>
</ListView.View>
</ListView>
<graphsharp:GraphLayout Graph="{Binding MethodGraph}"/>
</Grid>
</UserControl>
public class ExplorationToolViewModel : ViewModelBase
{
private IBidirectionalGraph<object, IEdge<object>> _methodGraph;
public IBidirectionalGraph<object, IEdge<object>> MethodGraph
{
get { return _methodGraph; }
set
{
if (value != _methodGraph)
{
_methodGraph = value;
NotifyPropertyChanged("MethodGraph");
}
}
}
public ExplorationToolViewModel()
{
InitializeViewModel();
}
private void InitializeViewModel()
{
SelectedMethods = new ObservableCollection<Method>();
CreateGraph();
}
private void CreateGraph()
{
var g = new BidirectionalGraph<object, IEdge<object>>();
// add vertices
string[] vertices = new string[5];
for (int i = 0; i < 5; i++)
{
vertices[i] = i.ToString();
g.AddVertex(vertices[i]);
}
// add edges
g.AddEdge(new Edge<object>(vertices[0], vertices[1]));
g.AddEdge(new Edge<object>(vertices[1], vertices[2]));
g.AddEdge(new Edge<object>(vertices[2], vertices[3]));
g.AddEdge(new Edge<object>(vertices[3], vertices[1]));
g.AddEdge(new Edge<object>(vertices[1], vertices[4]));
MethodGraph = g;
}
}
다행히 숨김 코드
public partial class ExplorationControl : UserControl
{
public ExplorationControl()
{
InitializeComponent();
// set the datacontext
DataContext = InteractiveExplorationPackage.ExplorationToolViewModel;
}
}
의 ViewModel, 내가 할 수있는 C 전체 프로젝트를 컴파일하지만 런타임에 XAML의 다음 오류가 태그 (필요한 태그 바로 위)에 발생합니다.
'GraphSharp.Controls, PublicKeyToken = null'또는 해당 종속성 중 하나를로드 할 수 없습니다. . 시스템에서 파일을 찾을 수 없습니다.
그러나 어셈블리를 참조했는데 참조 목록에 나열되어 있습니다. 무엇이 문제입니까? Visual Studio 패키지 (플러그인)을 쓸 때 어셈블리가 평소보다 다른 방법으로 참조되어야 할 수 있습니까?
편집 : 방금 다른 프로젝트에서 작동 시키려고 했으므로 일반 WPF 응용 프로그램을 설정하고 위의 모든 작업을 수행했습니다. 이 솔루션에서 모든 것이 제대로 작동합니다! 너무 이상해!
희망을 당신이 도와 줄 수 있습니다 :-) 최고입니다!
감사합니다! 나는 이미 그것을 시도하고 그것은 동일한 오류를 가져옵니다. 또한 프로젝트에 서명하지 않았을 때 (참조 된 어셈블리도 서명되지 않은 상태로 유지 될 수 있음) 오류가 남아 있습니다. 매우 이상한 것은 그것이 20 가지 경우 중 하나에서 작동한다는 것입니다! GraphLayout과 ZoomControl을로드하고 올바르게 사용할 수 있습니다! 나는 내가 할 수있는 모든 것을 거의 시도했기 때문에 곧 미치게된다. 좀 더 팁이 있다면 아주 좋을 것입니다! 지금까지 고마워! – Biocoder
서명 (강한 이름) 문제인지 여부를 시도했습니다. 그러나 그렇지 않습니다. 그래프 # 소스 코드를 사용하고 어셈블리에 직접 서명하거나 자신의 프로젝트 서명을 취소하십시오 ([link] (http://msdn.microsoft.com/en-us/magazine/cc163583.aspx)). 문제가 해결되었습니다. 물론 지금은 NuGet에서로드 된 최신 버전을 사용하고 있습니다. – Biocoder