Unknown Build Error using WPF Toolkit

倾然丶 夕夏残阳落幕 提交于 2019-11-30 00:45:12

问题


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?


回答1:


You need to add a reference to WPFToolkit.dll (Not just System.Windows.Controls.Input.Toolkit).




回答2:


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.




回答3:


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.

来源:https://stackoverflow.com/questions/2447657/unknown-build-error-using-wpf-toolkit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!