Visual Studio extension could not find a required assembly
Asked Answered
R

3

7

I wrote an extension for Visual Studio 2013. Because of bloody ComboBox bug, I had to include System.Windows.Interactivity to my project. To add more details:

  1. <Project> uses additional solution assembly, say <Project>.Editor, which contains the physical editor.
  2. <Project>.Editor references System.Windows.Interactivity
  3. <Project> references System.Windows.Interactivity as well. In fact, I'm using nuget to load Expression.Blend.Sdk package (it's compatible with WPF 4.5)

Effect: When part of editor, which contains mentioned ComboBox displays, I immediately get an exception:

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I'm running the extension in the experimental instance and the folder:

C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0

contains System.Windows.Interactivity.dll, but for some reason it seems not to be seen by the IDE.

What's even more weird, I'm using other additional packages, like IronPython and they never caused me such trouble.

How can I fix that?


Edit: In response to comments

Actually, the InnerException contains field called FusionLog, which contains the following:

=== Pre-bind state information ===
LOG: DisplayName = System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35 | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\<user>\AppData\Local\Temp\devE4FC.tmp
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PublicAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Microsoft/TemplateProviders/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/CommonExtensions/Platform/Debugger/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/PrivateAssemblies/DataCollectors/x86/System.Windows.Interactivity/System.Windows.Interactivity.EXE.

But there's more. I used ProcMon to check, where Visual Studio looks for that DLL and noticed in the end:

08:46:46,7508050    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
08:46:46,7509231    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity.EXE  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a
08:46:46,7510379    devenv.exe  7544    CreateFile  C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\Lib\System.Windows.Interactivity.DLL  NAME NOT FOUND  Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a

The Lib folder contains a few Python modules I'm using (for scripting purposes, as I'm using IronPython). And, ironically, the assembly is in the

C:\Users\<user>\AppData\Local\Microsoft\VisualStudio\12.0Exp\Extensions\<Company>\<Extension>\1.0\

folder (without Lib). But Visual Studio omits it in its search despite fact, that it's the most natural place to search (as requesting assembly resides there as well)

Recess answered 31/3, 2015 at 6:36 Comment(7)
Can you try to capture a binding log with the assembly binding log viewer to see where fusion tries to load that assembly from?Peirsen
@Peirsen I edited my post to include more information.Recess
Try copying that dll in any of the paths mentioned in the log. I would personally put that assembly in ...\PublicAssembliesPeirsen
@Peirsen Sure, I tried earlier and it worked, but I cannot ask users of the plugin to manually copy assembly somewhere :) The question is, how can I inform Visual Studio where to look for the assembly? And why IronPython loads without problems and System.Windows.Interactivity does not?Recess
Sure, at least we established it is a binding issue not something else obscures...Peirsen
@Peirsen I have a working theory about IronPython and System.Windows.Interactivity. IronPython is loaded from my plugin's code, while the latter is loaded from XAML, so the assembly responsible for attempting to load System.Windows.Interactivity is PresentationFramework.dll. That assembly, in turn, works in context of application, which in this case is Visual Studio, so it uses its folders to seek for the assembly and obviously fails.Recess
@Peirsen My idea is to force-load System.Windows.Interactivity from the code before that XAML file is being parsed, such that PresentationFramework.dll won't try to find it. I'm in the process of preparing such code.Recess
R
7

This is a workaround for this problem. I don't like it, but it works :)

The solution is force load the assembly from the source code, such that PresentationFramework won't have to seek for it during parsing of XAML file. For instance:

private static void LoadSystemWindowsInteractivity()
{
    // HACK: Force load System.Windows.Interactivity.dll from plugin's 
    // directory
    typeof(System.Windows.Interactivity.Behavior).ToString();
}

static MyEditorFactory()
{
    LoadSystemWindowsInteractivity();
}
Recess answered 31/3, 2015 at 8:11 Comment(0)
M
2

I had same problem. Below solution works for me.

  1. Create a text file name as "MyDef.pkgdef"
  2. Change content to

[$RootKey$\BindingPaths{some_guid}]
"$PackageFolder$"=""

  1. Add an asset in .vsixmanifest file

<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="File" Path="MyDef.pkgdef" />

  1. Be sure referenced dll must be signed and "Copy Local" attribute must be true.
Medius answered 15/12, 2016 at 8:27 Comment(0)
K
0

Using Microsoft.Xaml.Behaviors.Wpf instead of System.Windows.Interactivity the problem goes away.

Here's how to migrate: https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/ (Basically: install nuget, replace xmlns namespaces in xaml files.)

Kissiah answered 20/2, 2020 at 8:20 Comment(1)
I'm currently using Microsoft.Xaml.Behaviors.Wpf and I still had this exact problem. As soon as I did what was suggested in this comment the problem went away. "Another thought that might help some: At least one element from assembly "i" must be named, so that VS correctly hooks up the assembly. <i:InvokeCommandAction Command="{Binding MyCommand}" x:Name="interactivityFix" /> – Amadeusz Wieczorek Jun 18 '14 at 16:44"Ally

© 2022 - 2024 — McMap. All rights reserved.