title: Prism assembly reference failure: System.Windows.Interactivity
body: <p>I have C#/WPF Prism (v4.0) app that has a persistent problem loading/resolving the System.Windows.Interactivity dll that comes with the Prism library. I've been working for three days straight trying to debug/solve this problem. I've learned a ton about .Net assembly resolution, but no luck so far on my problem, so I thought I'd turn to the StackOverflow community in a desperate plea for help. :)</p>
  
  <p>I have a module running as part of a larger Prism app, which needs to reference System.Windows.Interactivity in order to add behaviors. Thus I have a XAML user control specifying the namespace as follows:</p>
  
  <pre><code>&lt;UserControl x:Class="MyApp.Modules.SourcesModule.myView"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"&gt;
  </code></pre>
  
  <p>And then I am trying to set a behavior on a child element of that UserControl as follows:</p>
  
  <pre><code>&lt;ListBox Name="myListBox"&gt;
      &lt;i:Interaction.Triggers&gt;
          &lt;i:EventTrigger EventName="SelectionChanged"&gt;
              &lt;i:InvokeCommandAction Command="{Binding SomeCommandOrOther}"/&gt;
          &lt;/i:EventTrigger&gt;
      &lt;/i:Interaction.Triggers&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>Oddly, the project builds fine, and when typing in the associate code-behind file and <em>I can even get Intellisense auto-completion</em> for objects in the System.Windows.Interactivity namespace.</p>
  
  <p>However, <em>at runtime only</em>, I get a XamlParseException on the above ListBox element.</p>
  
  <pre><code>Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 
  </code></pre>
  
  <p>The InnerException is of the type System.IO.FileNotFoundException</p>
  
  <pre><code>"Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35"
  </code></pre>
  
  <p>...which, as I have learned from reading about assembly resolutions, usually suggests a problem resolving a strongly-named assembly rather than merely an inability to find the dll on disk (as the exception type would suggest).</p>
  
  <p>The Fusion log information is as follows, including warning about partial binding for the assembly in question:</p>
  
  <pre><code>=== Pre-bind state information ===
  LOG: User = aricebo-array\me
  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:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/
  LOG: Initial PrivatePath = NULL
  Calling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
  ===
  LOG: This bind starts in default load context.
  LOG: No application configuration file found.
  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:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/System.Windows.Interactivity.DLL.
  LOG: Attempting download of new URL file:///C:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/System.Windows.Interactivity/System.Windows.Interactivity.DLL.
  LOG: Attempting download of new URL file:///C:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/System.Windows.Interactivity.EXE.
  LOG: Attempting download of new URL file:///C:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/System.Windows.Interactivity/System.Windows.Interactivity.EXE.
  </code></pre>
  
  <p>Interestingly, if I look at my built project using the IL disassembler (ildasm.exe), System.Windows.Interactivity is not listed in the manifest as one of the referenced assemblies, though the other referenced Prism dlls show up there just fine. For example:</p>
  
  <pre><code>.assembly extern Microsoft.Practices.Prism
  {
    .publickeytoken = (31 BF 38 56 AD 36 4E 35 )                         // 1.8V.6N5
    .ver 4:0:0:0
  }
  .assembly extern Microsoft.Practices.Unity
  {
    .publickeytoken = (31 BF 38 56 AD 36 4E 35 )                         // 1.8V.6N5
    .ver 2:0:414:0
  }
  </code></pre>
  
  <p>This problem is similar to the one mentioned in this other StackOverflow question: <a href="https://stackoverflow.com/questions/7286774/referencing-the-correct-system-windows-interactivity-dll-from-prism-application">Referencing the correct System.Windows.Interactivity dll from Prism application</a>. However, I am following the prescribed solution mentioned there (i.e., using the Prism version of System.Windows.Interactivity), to no avail. Just for fun, I have also tried using the System.Windows.Interactivity dlls that come with both the Expression Blend 3 and 4 SDKs (separately of course), but no luck with those either.</p>
  
  <p>I'm not doing anything differently in how I've loaded the System.Windows.Interactivity dll from how I've loaded all the other dlls that come with the Prism library (they all reside in a /lib folder in my solution, and I've added them using the "Add reference" > "Browse" menu in Visual Studio 2010 and pointing to those dlls on disk sitting all together in one directory.)</p>
  
  <p>Any leads on where to turn next would be most appreciated! Many thanks.</p>