简体   繁体   English

使用Expression Blend SDK行为损坏了Visual Studio Designer

[英]Visual Studio Designer broken using Expression Blend SDK Behavior

I'm running into a problem with the new Expression Blend behaviors. 我遇到了新的Expression Blend行为问题。

I have a customized Behavior<T> class developed using the Expression Blend 3 SDK. 我有一个使用Expression Blend 3 SDK开发的自定义Behavior<T>类。

The behavior works properly, and the solution compiles. 该行为可以正常工作,并且解决方案可以编译。 That is perfect. 太好了 I have all of my references (System.Windows.Interactivity.dll + Microsoft.Expression.Interactions.dll) setup in my projects that reference the behavior. 我在引用行为的项目中拥有所有引用(System.Windows.Interactivity.dll + Microsoft.Expression.Interactions.dll)。

In addition, as I mentioned, Visual Studio compiles the project fine. 另外,正如我提到的,Visual Studio可以很好地编译项目。

However, if I load the XAML file in the Visual Studio designer, I get the following error after the solution compiles: 但是,如果我在Visual Studio设计器中加载XAML文件,则在解决方案编译会出现以下错误:

Error 1 The attachable property 'Behaviors' was not found in type 'Interaction'. 错误1在类型“交互”中找不到可连接属性“行为”。 C:\\Path\\To\\MyFile.xaml 19 14 MyApplication C:\\ Path \\ To \\ MyFile.xaml 19 14 MyApplication

That line of the file is the first line of the following: 文件的这一行是以下内容的第一行:

<Interactivity:Interaction.Behaviors>
    <Behaviors:DoubleTextBoxBehavior />
</Interactivity:Interaction.Behaviors>

My window reference is setup with: 我的窗口参考设置为:

xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

I've even eliminated my custom behavior as a possibility. 我什至消除了自定义行为的可能性。 I can just include the following line, and "break" the designer: 我可以只包含以下行,并“破坏”设计器:

<Interactivity:Interaction.Behaviors />

As far as I can tell, this should work. 据我所知,这应该工作。 There shouldn't be an error. 不应有错误。 The compiler handles this fine, but Visual Studio won't load this in the designer any time I add the behavior line. 编译器可以很好地解决此问题,但是,无论何时添加行为行,Visual Studio都不会在设计器中加载它。

Does anybody have an idea of what can cause this, and how to fix it? 是否有人知道会导致什么的原因以及如何解决?


Edit: 编辑:

I've done some more testing, and this appears to be an error occurring only within the Windows Presentation Foundation Designer windows within Visual Studio 2008 (with sp1). 我做了更多测试,这似乎是只在Visual Studio 2008(带有sp1)的Windows Presentation Foundation Designer窗口内发生的错误。 The project works fine, and no error is reported, provided I only use the XML editor. 只要我仅使用XML编辑器,该项目就可以正常工作,并且不会报告任何错误。 If I open this in the Designer, however, it reports the error and shows a Problem Loading designer. 但是,如果我在设计器中打开它,它将报告错误并显示问题加载设计器。

The error does not appear unless the XAML file is opened in the VS designer. 除非在VS设计器中打开XAML文件,否则不会出现该错误。

This is due to known issue in Visual Studio, and is addressed by a hotfix: KB958017 . 这是由于Visual Studio中的已知问题引起的,并通过修补程序KB958017解决

This can be corrected by downloading and installing the KB958017 Rollup Fixes for Visual Studio Designer . 可以通过下载并安装KB958017 Visual Studio Designer汇总修补程序来纠正此问题。

I've tried to reproduce your issue, but I couldn't. 我试图重现您的问题,但无法。 I have created the following WPF application: 我创建了以下WPF应用程序:

<Window x:Class="WpfBehaviorsTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Title="Window1" Height="300" Width="300">
<Grid>
    <Interactivity:Interaction.Behaviors/>
</Grid>
</Window>

Everything works just fine before and after I compile my project. 在我编译项目前后,一切都很好。 Could you test if this works for you? 您能测试一下是否适合您吗? What version of MS Blend SDK do you use? 您使用什么版本的MS Blend SDK? What version of Visual Studio? 什么版本的Visual Studio? Just to be sure: we speak about WPF application, not Silverlight, correct? 只是要确保:我们谈论的是WPF应用程序,而不是Silverlight,对吗?

Update: You have exactly the same configuration as I do. 更新:您的配置与我完全相同。 The only problem is that it works here, but doesn't work on your side. 唯一的问题是它在这里有效,但对您不利。 Let's squash this insect by the following checks: 让我们通过以下检查将这种昆虫压扁:

  1. What version of "System.Windows.Interactivity" assembly get's loaded by designer? 设计者可以加载哪个版本的“ System.Windows.Interactivity”程序集? You could run another instance of MS Visual Studio and attach to the first VS process with "buggy"-designer. 您可以运行MS Visual Studio的另一个实例,并使用“ buggy” -designer附加到第一个VS进程。 Go to Debug->Windows->Modules and check the version of System.Windows.Interactivity.dll. 转到“调试”->“ Windows”->“模块”,然后检查System.Windows.Interactivity.dll的版本。 If it looks good you still can go and double check it with Reflector. 如果看起来不错,您仍然可以使用Reflector再次检查它。 Does it has Interaction class? 互动课吗? Is there BehaviorsProperty in it? 里面有BehaviorsProperty吗?

  2. What exactly is happening there inside? 里面到底发生了什么? If assembly that we've checked in step 1 is correct, let's run heavy artillery. 如果我们在第1步中检查的组装正确,那么我们就运行重型火炮。 In fact I effectively use this approach quite often, whenever I have VS/Blend designer issues. 实际上,每当遇到VS / Blend设计器问题时,我都会经常有效地使用这种方法。 Just run another instance of Visual Studio. 只需运行Visual Studio的另一个实例。 Turn on breaks on all CLR exceptions (Debug -> Exceptions-> Check the box after CLR Exceptions). 打开所有CLR异常的中断(调试->异常->选中CLR异常后的复选框)。 It might also help to turn on .NET source code debugging . 这也可能有助于打开.NET源代码调试 Attach to the instance with invalid designer. 使用无效的设计器附加到实例。 Reload designer. 重新加载设计器。 Now, instead of seeing confusing message, attached Studio will bring us to the very heart of the Exception. 现在,附加的Studio不再看到令人困惑的消息,而是将我们带到了Exception的核心。 What's there? 什么东西在那里?

I am using VS2010 and I experienced the same problem but found a solution. 我正在使用VS2010,但遇到相同的问题,但找到了解决方案。

I had a two projects in my solution. 我的解决方案中有两个项目。 Project "A" that used the Behaviors in a silverlight control (defined in the xaml). 在Silverlight控件(在xaml中定义)中使用了“行为”的项目“ A”。 I then referenced the control in project "A" inside the active silverlight project "B" which was being executed. 然后,我引用了正在执行的活动Silverlight项目“ B”中的项目“ A”中的控件。 I kept getting the error The attachable property 'Behaviors' was not found in type 'Interaction' 我不断收到错误消息在“交互”类型中找不到可附加属性“行为”

When I added the System.Windows.Interactivity reference to project "B" it fixed my runtime error. 当我将System.Windows.Interactivity引用添加到项目“ B”时,它修复了我的运行时错误。

I am not sure why that reference was not being loaded because it was being utilized by the control from project "A" but it wasn't. 我不确定为什么没有加载该引用,因为该引用已被项目“ A”中的控件使用,但没有加载。 Oh well. 那好吧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM