wpf 从 Prism 应用程序引用正确的 System.Windows.Interactivity dll

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7286774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 23:03:59  来源:igfitidea点击:

Referencing the correct System.Windows.Interactivity dll from Prism application

wpfprismexpression-blend

提问by Josh

I have a WPF Prism application that I'm building. The application is to the point where I want to be able to add EventTriggers to controls so I can call commands on the underlying view model. However, I can't seem to reference the correct DLLs to make the project run. Currently, I'm referencing Microsoft.Expression.Interactionsand System.Windows.Interactivityfrom the C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0\Librariesdirectory.

我有一个正在构建的 WPF Prism 应用程序。该应用程序达到了我希望能够将 EventTriggers 添加到控件的程度,以便我可以在底层视图模型上调用命令。但是,我似乎无法引用正确的 DLL 来运行项目。目前,我正在引用Microsoft.Expression.InteractionsSystem.Windows.Interactivity来自C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0\Libraries目录。

When I run the module, I get this error:

当我运行模块时,出现此错误:

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”或其依赖项之一。
该系统找不到指定的文件。

I checked the System.Windows.Interactivityassembly in reflector and can see that it references:

我检查了System.Windows.Interactivity反射器中的组件,可以看到它引用了:

  • mscorlib
  • PresentationCore
  • PresentationFramework
  • System
  • System.Core
  • System.Xaml
  • WindowsBase
  • mscorlib
  • 演示核心
  • 演示框架
  • 系统
  • 系统核心
  • 系统文件
  • 视窗基地

All the references point to the 4.0 framework. I've referenced each from the .NET reference tab, making sure that each one is the 4.0 version. All these references are being loaded from the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0directory.

所有引用都指向 4.0 框架。我已经从 .NET 参考选项卡中引用了每一个,确保每一个都是 4.0 版本。所有这些引用都是从C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0目录中加载的。

Is there another download I need for the System.Windows.Interactivityand Microsoft.Expression.Interactionsassemblies to work in my environment?

System.Windows.InteractivityMicrosoft.Expression.Interactions程序集是否需要其他下载才能在我的环境中工作?

采纳答案by Mike Post

For some reason that I still cannot fathom, Prism includes it's own version of the Blend SDK assemblies. So you should reference Microsoft.Expression.Interactions.dll and System.Windows.Interactivity.dll from the Lib\Desktop folder of the Prism distribution (assuming you're using Prism v4) rather than from the Blend SDK installation.

出于某种我仍然无法理解的原因,Prism 包含它自己版本的 Blend SDK 程序集。因此,您应该从 Prism 发行版的 Lib\Desktop 文件夹(假设您使用的是 Prism v4)而不是从 Blend SDK 安装中引用 Microsoft.Expression.Interactions.dll 和 System.Windows.Interactivity.dll。

回答by Ryan Norbauer

For people landing on this page experiencing this problem but where the above given solution isn't working, you might have a look at: Prism assembly reference failure: System.Windows.Interactivity

对于登陆此页面但遇到此问题但上面给出的解决方案不起作用的人,您可以查看:Prism assembly reference failure: System.Windows.Interactivity