【发布时间】:2015-08-14 18:51:31
【问题描述】:
我致力于解决我拥有多个 WPF 项目的解决方案。我使用 MVVM 架构,并且我有一个主应用程序,它从同一解决方案中的另一个项目继承用户控件。主应用程序是一个简单的 wpf 应用程序项目,另一个是类库。我在类库用户控件的初始化组件上收到此错误。该用户控件需要此组件。我该如何解决这个问题/错误?谁能帮我?谢谢。
附加信息:显示名称的程序集 “System.Windows.Interactivity”未能加载到“加载”绑定中 ID 为 1 的 AppDomain 的上下文。失败的原因是: System.IO.FileLoadException:无法加载文件或程序集 'System.Windows.Interactivity,版本=4.5.0.0,文化=中性, PublicKeyToken=31bf3856ad364e35' 或其依赖项之一。这 定位程序集的清单定义与程序集不匹配 参考。 (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>
【问题讨论】:
-
您使用的是哪个版本的 Visual Studio?此外,安装 blend 时会安装交互性,因此如果您将 dll“添加”到项目中,则可能缺少其他步骤。最简单的解决方案是利用 nuget 包管理器。更多信息可以找到at this SO question
-
我有 Visual Studio 2013 终极版
-
我建议您删除包含在项目结构中的已安装参考(我假设您手动执行此操作)。然后我会利用 nuget 包管理器,然后获得 MVVM Light(附带消息,如果您使用的是 4.5,您可能会在带有 MVVM 和交互性的 WPF/C# 应用程序中使用它)
-
我清理了我的解决方案,并删除了对我的 System.Windows.Interactivity.dll 的所有引用,并且在我使用了 nuget 包管理器之后,现在我在启动 xaml 文件初始化时遇到了同样的错误. :(
标签: c# .net wpf mvvm .net-assembly