Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio extension could not find a required assembly

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)

like image 944
Spook Avatar asked Mar 31 '15 06:03

Spook


2 Answers

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();
}
like image 60
Spook Avatar answered Oct 13 '22 13:10

Spook


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.
like image 40
kaya Avatar answered Oct 13 '22 13:10

kaya