我有C#/ WPF Prism(v4.0)应用程序有加载/解决Prism库附带的System.Windows.Interactivity dll的持久性问题。我一直在尝试调试/解决这个问题,一直工作三天。我已经学会了大量的.Net程序集解决方案,但在我的问题上至今没有运气,所以我想我会转向StackOverflow社区,以绝望的呼吁请求帮助。 :)棱镜程序集引用失败:System.Windows.Interactivity
我有一个模块作为更大的Prism应用程序的一部分运行,它需要引用System.Windows.Interactivity以添加行为。因此,我有一个XAML用户控制指定的命名空间如下:
<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">
然后我想设置一个行为用户控件的子元素如下:
<ListBox Name="myListBox">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding SomeCommandOrOther}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>
奇怪的是,该项目生成的很好,并且在关联代码隐藏文件和中输入时,我甚至可以为System.Windows.Interactivity命名空间中的对象获取Intellisense自动完成。
但是,在运行时只有,我在上面的ListBox元素上得到一个XamlParseException。
Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
的的InnerException是类型System.IO.FileNotFoundException
"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"
...这,因为我从阅读有关大会决议了解到,通常表明解决强命名程序集的问题而不仅仅是无法在磁盘上找到dll(因为异常类型会提示)。
融合日志信息如下,包括问题的警告有关部分装订的装配:
=== 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.
有趣的是,如果我查看使用IL反汇编程序(Ildasm.exe),系统建立我的项目.Windows.Interactivity没有在清单中作为引用的程序集之一列出,但其他引用的Prism dll显示在那里很好。例如:
.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
}
这个问题类似于此的其他StackOverflow的问题中提到的一个:Referencing the correct System.Windows.Interactivity dll from Prism application。但是,我遵循上面提到的规定解决方案(即使用System.Windows.Interactivity的Prism版本),无济于事。为了好玩,我也尝试过使用Expression Blend 3和4 SDK(当然要单独使用)提供的System.Windows.Interactivity dll,但没有运气。
我没有做任何不同的事情,在我如何加载System.Windows.Interactivity DLL从我如何加载所有其他与棱镜库附带的DLL(它们都驻留在/ lib文件夹中我的解决方案,我已经使用Visual Studio 2010中的“添加引用”>“浏览”菜单添加了它们,并指向磁盘上的这些DLL全部放在一个目录中。)
任何导致下一个转向的位置将不胜感激!非常感谢。
是否有在GAC一个版本?你正在建立'任何CPU',并在开发时引用64位,但在运行时32位绑定? FWIW,我没有线索。 – 2012-03-10 23:08:06
'gacutil -l'确认在GAC中没有运行System.Windows.Interactivity的版本。为了回答你的问题,我正在构建“任何CPU”作为项目属性中的平台目标。我的测试机器/操作系统是64位的。但是,我不知道足以在运行时回答有关32位绑定的问题。你能告诉我怎么检查吗?谢谢! – 2012-03-10 23:23:33
尝试构建为x86,看看会发生什么 – 2012-03-10 23:28:20