3

I have an existing WPF application from which I'd like to make a VisualStudio extension.

Basically, I have a xaml window in which I use the library Extended.Wpf.Toolkit for AvalonDock. This application works perfectly without any issue.

I tried to re-use the same window in my extension project and I got XamlParseException on load

Here is the sample code which fails :

<Window x:Class="Company.VisualStudioExtension.Window2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
    Title="Window2" Height="300" Width="300">
<Grid>
    <xcad:DockingManager AllowMixedOrientation="True" BorderThickness="1">
        <xcad:DockingManager.DocumentHeaderTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Test" />
                </StackPanel>
            </DataTemplate>
        </xcad:DockingManager.DocumentHeaderTemplate>
        <xcad:LayoutRoot x:Name="_layoutRoot">
            <xcad:LayoutPanel Orientation="Horizontal">
                <xcad:LayoutAnchorablePane DockWidth="300">
                </xcad:LayoutAnchorablePane>
            </xcad:LayoutPanel>
        </xcad:LayoutRoot>
    </xcad:DockingManager>
</Grid>

The exception is highlighted on the following line :

            <xcad:LayoutPanel Orientation="Horizontal">

"The method or operation is not implemented."

EDIT

It seems registering all AvalonDock dll in GAC fixes the issue but obviously, it's not an acceptable solution...

I guess these dll are not properly registered while running as an Extension, I propably need to reference them in a specific way... for now, they are referenced in Extension's csproj + CopyLocal=True

EDIT2

Added source code to reproduce the issue https://github.com/MrLuje/VSPackage_NotWorking

There are 2 projects :

  • a WPF app with a working code in MainWindow
  • a VS Extension with non-working code in Window1 (in debug, you need to click in Tools > "My Command name")
MrLuje
  • 637
  • 6
  • 15
  • Sounds like LayoutPanel is orientation-agnostic. Do you need to set an Orientation? If not, remove it and move on. If so, [edit] and add details. –  May 04 '15 at 14:16
  • I don't need them but the issue still persist, same line – MrLuje May 04 '15 at 18:42
  • You need to capture the exception details in order to tell what method isn't implemented. –  May 04 '15 at 18:46
  • I guess the type itself (LayoutPanel) is failing to load... edited the initial post, seems like a reference issue – MrLuje May 04 '15 at 18:53
  • Installing to the GAC is an acceptable solution, normally. Am guessing you're doing an xcopy install, in this case. NIE doesn't indicate that. Perhaps fusion is loading a different version from somewhere else on your machine. Lots of guesses in here. Exception details and fusion logging would answer them, probably. You can add an answer below to close this out. –  May 04 '15 at 19:04

2 Answers2

3

I found an easier solution, 'ProvideBindingPath' this will add your current extension folder to the resolution folders of dlls.

 [ProvideBindingPath]
 public sealed class MainWindowPackage : Package
 {
 }

based on solution purposed in: VSIX - Cannot load file or assembly of a referenced dll

The solution of adding to the gac wont work 'as is'...VSIX extensions dont allow register on the gac, maybe a workaround will be run gacutil.

Community
  • 1
  • 1
Kanekotic
  • 2,824
  • 3
  • 21
  • 35
0

Followed @Will's answer and went with the following code which works fine :

protected override void Initialize()
{
    base.Initialize();

    InstallAvalonToGac();
}

private static void InstallAvalonToGac()
{
    var dlls = new string[]
    {
        "Xceed.Wpf.AvalonDock.dll",
        "Xceed.Wpf.DataGrid.dll",
        "Xceed.Wpf.Toolkit.dll"
    };

    foreach (var dll in dlls)
    {
        var fullpath = Path.Combine(Environment.CurrentDirectory, dll);
        new System.EnterpriseServices.Internal.Publish().GacInstall(fullpath);
    }
}
MrLuje
  • 637
  • 6
  • 15