1

I work on solution where I have more than one WPF projects. I use the MVVM architecture, and I have a main app which inherit User Controls from another projects in the same solution. The main app is a simple wpf application project and the other is class libraries. I got this error on Initialization Component from the class library user control. That user control needs this assamblies. How can I solve this problem/error? Can anyone help me? Thank you.

Additional information: The assembly with display name 'System.Windows.Interactivity' failed to load in the 'Load' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileLoadException: 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)

    this is the structure:
          MainProject
            ->Model
            ->ViewModel
            ->DLL
              ->System.Windows.Interactivity.dll(I use this reference)
            ->View
              ->ClassLibraryView.xaml
              code:
        <Window x:Class="MainProject.Views.ClassLibraryView"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:userControl="clr-namespace:ClassLibrary.View;assembly=ClassLibrary"              
                Title="main" Height="500" Width="800" MinWidth="600" MinHeight="400">

            <Grid>
                <userControl:ClassLibraryUserControl/>
            </Grid>

        </Controls:MetroWindow>

-------------------------
    ClassLibrary
     ->Model
     ->ViewModel
     ->View
        ->ClassLibraryUserControl.xaml
        code:
<UserControl x:Class="ClassLibrary.View.ClassLibraryUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:b="clr-namespace:ClassLibrary.Behavior"
             xmlns:u="clr-namespace:ClassLibrary.Utility"
             mc:Ignorable="d" 
             d:DesignHeight="350" d:DesignWidth="525">
    <Grid>
           ...
    </Grid>
</UserControl>
Bo Persson
  • 90,663
  • 31
  • 146
  • 203
kaan_93
  • 85
  • 1
  • 10
  • Which version of Visual Studio are you using? Also, interactivity is installed when blend is installed, so if you "added" the dll to your project, there may be other steps you are missing. The easiest solution is to take advantage of nuget package manager. More information can be found [at this SO question](http://stackoverflow.com/q/8360209/3109213) – Stunna Aug 14 '15 at 18:58
  • I have Visual Studio 2013 Ultimate edition – kaan_93 Aug 14 '15 at 19:02
  • 1
    I would recommend then getting rid of the installed reference you included into your project structure (I assume you did this manually). I'd then take advantage of nuget package manager, and then get MVVM Light (comes with messaging which you might use in your WPF/C# application with MVVM as well as interactivity, if you are using 4.5) – Stunna Aug 14 '15 at 19:04
  • I cleaned up my solution, and I deleted all reference to my System.Windows.Interactivity.dll , and after I used the nuget Package Manager, now I got the same error on the startup xaml file initialization. :( – kaan_93 Aug 14 '15 at 19:22

1 Answers1

1

Looks to me like you are using the wrong version of the DLL. That DLL has a bunch of different versions floating around. You need the one for your version of .NET. Are you referencing the 4.5 version?

SledgeHammer
  • 7,338
  • 6
  • 41
  • 86
  • 2
    thank you. This was a very usefull answer. My mistake was that I used an older version of that dll than the .Net framework version. And also thanks to Stunna's answer, I used tha Nuget Package Mangager, it is much better. – kaan_93 Aug 15 '15 at 21:18