159

My project missing System.Windows.Interactivity. Google says that I have to install Expression Blend, but on my other computer I have this library and I don't have Expression Blend installed. So there should be another way to obtain System.Windows.Interactivity? What should I do? (right now i don't have another computer so I can not just copy this library :)

Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
Oleg Vazhnev
  • 23,239
  • 54
  • 171
  • 305

13 Answers13

259

Although this issue is quite old, i think this is relevant news / the most recent answer: Microsoft open-sourced XAML Behaviours and posted a blog post how to update to this version: https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/

To save you a click, this is the main steps to migrate:

  1. Remove reference to “Microsoft.Expression.Interactions” and “System.Windows.Interactivity”
  2. Install the Microsoft.Xaml.Behaviors.Wpf NuGet package.
  3. XAML files – replace the xmlns namespaces http://schemas.microsoft.com/expression/2010/interactivity and http://schemas.microsoft.com/expression/2010/interactions with http://schemas.microsoft.com/xaml/behaviors
  4. C# files – replace the usings in c# files “Microsoft.Xaml.Interactivity” and “Microsoft.Xaml.Interactions” with “Microsoft.Xaml.Behaviors”
Jan
  • 3,825
  • 3
  • 31
  • 51
  • 19
    This is--now--absolutely the correct answer. I'm so glad Microsoft has finally done this. Thanks for posting it. I'm not sure how I missed the blog entry. There should be a newsletter for "Cool, new Microsoft NuGet packages." – skst Jun 26 '19 at 23:25
  • 3
    If Stackoverflow has emotions, I would use a hart for your answer – Ibrahim Kais Ibrahim Jul 09 '19 at 18:23
  • 3
    Should be the selected answer as of 2019. Thanks for taking time to add this important update. – mins Sep 19 '19 at 16:59
  • 2
    Worked for me. I updated solution from 2015 on VS2019. Thank you. – KulaGGin Oct 15 '19 at 08:20
  • 1
    In addition, if you're using any of the shapes in http://schemas.microsoft.com/expression/2010/drawing, you can use [this nuget package](https://www.nuget.org/packages/Microsoft.Expression.Drawing/) - no code changes are required. – Daniel Elkington Nov 25 '19 at 22:47
  • 2
    [Prism.Wpf](https://www.nuget.org/packages/Prism.Wpf/) package still has `System.Windows.Interactivity`. If you use the prism framework, you don't need to use `Microsoft.Xaml.Behaviors.Wpf`. – Jeong Hansol Apr 21 '20 at 08:55
  • 1
    After installing Microsoft.Xaml.Behaviors.Wpf, it works on my local Visual Studio 2019 but it fails on build agent. Nuget restore step is there before the build step. Any suggestions? – Sundeep Apr 30 '20 at 16:00
  • @Sundeep Have you had any luck with build agent? Have the same issue and no solution is working for me – n0ne Jan 13 '21 at 09:22
  • 1
    @n0ne: Yes, if it is your build server, make sure you update you have 2019 on your build server. – Sundeep Jan 14 '21 at 11:09
  • Probably it is easy to see but replace also ei with i inside EventTrigger if you use CallMethodAction. – Amadeus Jan 18 '22 at 18:30
  • 1
    I followed this guide and had the error "Unknown build error, Cannot resolve dependency [...] , because it has been preloaded. When using the reflection-only APIs, dependant assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event." after installing version 1.1.39 of the nuget package. Removing the dependency Microsoft.Xaml.Behaviors.Design solved the issue. Solution found with https://stackoverflow.com/a/8740734/18783212. – Libranova Apr 13 '22 at 08:17
  • 1
    Thank you - this helped a lot. Note for future readers: Don't be fooled by intellisense and on-the-fly error messages. It reports that it cannot find the Microsoft.Xaml.Behaviors assembly. Just rebuild the solution! – JeffRSon May 19 '22 at 09:56
  • @DanielElkington Looks like that nuget is no longer available. Any other options? – kong88 Oct 05 '22 at 19:25
120

The official package for behaviors is Microsoft.Xaml.Behaviors.Wpf.

It used to be in the Blend SDK (deprecated).
See Jan's answer for more details if you need to migrate.

H.B.
  • 166,899
  • 29
  • 327
  • 400
62

There is a new NuGet package that contains the System.Windows.Interactivity.dll that is compatible with:

  • WPF 4.0, 4.5
  • Silverligt 4.0, 5.0
  • Windows Phone 7.1, 8.0
  • Windows Store 8, 8.1

To install Expression.Blend.Sdk, run the following command in the Package Manager Console

PM> Install-Package Expression.Blend.Sdk

http://www.nuget.org/packages/Expression.Blend.Sdk/

H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144
Thomas
  • 2,368
  • 20
  • 22
24

The easiest way might be to get it from NuGet:

http://www.nuget.org/packages/System.Windows.Interactivity.WPF/

seabass2020
  • 1,093
  • 14
  • 12
22

With Blend for Visual Studio, which is included in Visual Studio starting with version 2013, you can find the DLL in the following folder:

C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.5\Libraries

You will have to add the reference to the System.Windows.Interactivity.dll yourself though, unless you use Blend for Visual Studio with an existing project to add functionality that makes use of the Interactivity namespace. In that case, Blend will add the reference automatically.

poke
  • 369,085
  • 72
  • 557
  • 602
  • 8
    This helped this fix my project. With Visual Studio 2017, we have to go in Visual Studio Installer and find it in the Individual Components (SDK category). – PRouleau Jul 27 '17 at 21:28
19

Sometimes, when you add a new library, in introduces a clashing version of System.Windows.Interactivity.dll.

For example, the NuGet package MVVM light might require v4.2 of System.Windows.Interactivity.dll, but the NuGet package Rx-XAML might require v4.5 of System.Windows.Interactivity.dll. This will prevent the the project from working, because no matter which version of System.Windows.Interactivity.dll you include, one of the libraries will refuse to compile.

To fix, add an Assembly Binding Redirect by editing your app.config to look something like this:

<?xml version="1.0"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Windows.Interactivity"
                          publicKeyToken="31bf3856ad364e35"
                          culture="neutral"/>
        <bindingRedirect oldVersion="4.0.0.0"
                         newVersion="4.5.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup>
  <appSettings>
    <add key="TestKey" value="true"/>
  </appSettings>
</configuration>

Don't worry about changing the PublicKeyToken, that's constant across all versions, as it depends on the name of the .dll, not the version.

Ensure that you match the newVersion in your appConfig to the actual version that you end up pointing at:

enter image description here

riQQ
  • 9,878
  • 7
  • 49
  • 66
Contango
  • 76,540
  • 58
  • 260
  • 305
  • You did the exact same post here, http://stackoverflow.com/questions/13514027/could-not-load-file-or-assembly-system-windows-interactivity Multiple points :) – pix Aug 16 '16 at 13:04
16

Alternative solution is to modify your current Visual Studio installation in the Visual Studio Installer

Win+R %ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vs_installer.exe

adding the Blend for Visual Studio SDK for .NET 'Individual component' under 'SDKs, libraries, and frameworks':

enter image description here after adding this component System.Windows.Interactivity should appear in its regular location Add Reference/Assemblies/Extensions.


It appears this would only work for VS2017 or earlier. For later versions, please refer to other answers.

wondra
  • 3,271
  • 3
  • 29
  • 48
6

I have had the exact same problem with a solution, that System.Windows.Interactivity was required for one of the project in Visual Studio 2019, and I tried to install Blend for Visual Studio SDK for .NET from Visual Studio 2019 Individual components, but it did not exist in it.

The consequence of that, I was not able to build the project in my solution with repetitive of following similar error on different XAML parts of the project:

The tag 'Interaction.Behaviors' does not exist in XML namespace 'clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity'.

Image with all errors The above mentioned errors snapshot example

The solution, the way I solved it, is by installing Microsoft Expression Blend Software Development Kit (SDK) for .NET 4 from Microsoft.

Thanks to my colleague @felza, mentioned that System.Windows.Interactivity requires this sdk, that is suppose to be located in this folder:

C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0

In my case it was not installed. I have had this folder C:\Program Files (x86)\Microsoft SDKs with out Expression\Blend\.NETFramework\v4.0 folder inside it.

After installing it, all errors disappeared.

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137
2

It's in MVVM Light, get it from the MVVM Light Download Page.

Contango
  • 76,540
  • 58
  • 260
  • 305
  • 1
    Best Solution. Addition: use nuget `Install-Package MvvmLightLibs -Version 5.3.0` – hdev Jul 26 '17 at 14:43
2

I got it via the Prism.WPF NuGet-Package. (it includes Windows.System.Interactivity)

Halloween_Udo
  • 69
  • 2
  • 9
0

If you are working with MVVM Light you have to use the System.Windows.Interactivity Version 4.0 (the NuGet .dll wont work) that you can find under :

PathToProjectFolder\Software\packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll

Just add this .dll manually as Reference and it should be fine.

0

I was getting the following error using Visual Studio 2019:

System.Windows.Markup.XamlParseException: 'Could not load file or assembly 'System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

Our project is using packages.config and had NuGet references to MVVMLightLibs 5.4.1.1 and System.Windows.Interactivity.WPF 2.0.20525.

Guided by some of the other answers here, I realised the problem was a conflict between the version of the DLL that MVVMLight was using and the one our project was using. The solution was:

  • Remove the NuGet reference to System.Windows.Interactivity.
  • Added a Reference to packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll.
  • Add (in our case, update) a Binding Redirect to app.config:
<dependentAssembly>
    <assemblyIdentity name="System.Windows.Interactivity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
llane12
  • 1
  • 2
0

Use the following two NuGet packages

1.Microsoft.Xaml.Behaviors.wpf

2.Expression.Blend.Sdk.WPF

Moreover while installing VS2022 see option to install blend sdk. click on the checkbox while installing.If you have not found that check box then tick the UWP and then you can see that option while installing VS 2022.

Anindya
  • 2,616
  • 2
  • 21
  • 25