使用 WPF 工具包时出现未知构建错误
我安装了 2010 年 2 月 WPF 工具包,因为我对评估 AutoCompleteBox 控件很感兴趣,但取得的成功非常有限。我可以让该控件正常工作,但一旦我尝试在 XAML 中设置它的任何属性,我就会收到以下消息:
未知的构建错误,“无法解析对程序集的依赖关系”WPFToolkit,版本=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 因为它尚未预加载。使用 ReflectionOnly API 时,必须通过 ReflectionOnlyAssemblyResolve 事件预加载或按需加载依赖程序集。
我一直在新解决方案中的空白 WPF 窗口上对此进行测试。我猜我只是缺少引用或其他内容...这是 XAML(我没有向 .xaml.cs 添加任何内容):
<Window x:Class="WpfToolkitApplication.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
Title="Window1" Height="300" Width="300">
<Grid>
<toolkit:AutoCompleteBox Height="25"/>
</Grid>
</Window>
我添加的唯一引用是 System.Windows.Controls.Input.Toolkit 。有什么想法吗?
I installed the Feb 2010 WPF Toolkit as I'm interested in evaluating the AutoCompleteBox control and I'm having extremely limited success. I can get the control to work, but as soon as I try and set any of it's properties in XAML, I get the following:
Unknown build error, 'Cannot resolve dependency to assembly 'WPFToolkit, Version=3.5.40128.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
I've been testing this on a blank WPF window in a new solution. I'm guessing I'm just missing a reference or something... Here's the XAML (I've added nothing to the .xaml.cs):
<Window x:Class="WpfToolkitApplication.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
Title="Window1" Height="300" Width="300">
<Grid>
<toolkit:AutoCompleteBox Height="25"/>
</Grid>
</Window>
The only reference I've added is System.Windows.Controls.Input.Toolkit. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要添加对 WPFToolkit.dll 的引用(不仅仅是 System.Windows.Controls.Input.Toolkit)。
You need to add a reference to WPFToolkit.dll (Not just System.Windows.Controls.Input.Toolkit).
我已经遇到了这个问题,并且能够解决它。我的解决方案中有多个项目: A 是一个使用 VSM 并引用 WPFToolkit.dll 的 C# 库。 B 是一个 WPF 应用程序,在其 XAML 中包含 A,并且 B 有一个对 A 的项目引用。
当我收到错误时,我能够通过在 B 中添加对 WPFToolkit.dll 的引用来解决它。我将尝试将此问题提炼为一个简单的重现,并将其作为 Visual Studio 团队的错误归档。
I've hit this, and was able to work around it. I had multiple projects in my solution: A is a C# library that uses VSM and references WPFToolkit.dll. B is a WPF Application that includes A in its XAML, and B has a project reference to A.
When I got the error, I was able to resolve it by adding a reference to WPFToolkit.dll in B. I'm going to try to distill this issue to a simple repro and file it as a bug for the Visual Studio team.
如果您使用的是 VisualStudio 2010,则需要取消阻止此程序集,使其成为受信任的程序集。有关详细信息,请参阅这篇文章。
http://msdn.microsoft.com/en-us/ Library/ee890038(VS.100).aspx
添加引用后(按照上面的说明操作),您仍然需要将此行添加到您的 Windows xaml 中。
If you are using VisualStudio 2010 you need to unblock this assembly making it a trusted assembly. See this article for details.
http://msdn.microsoft.com/en-us/library/ee890038(VS.100).aspx
After adding the reference (following the instructions above) you still need to add this line to your windows xaml.