locked
Blend 3 Preview keeps crashing when adding behaviors, and doesn't show any behaviors RRS feed

  • Question

  • Hi, I'm using Expression Blend 3 preview with VS 2008 on Windows XP SP3 machine. I'm having several problems when working with behaviors.

    1.) When I create new WPF project in Blend 3 and add Microsoft.Expression.Interactivity.dll from the ..\Libraries\WPF directory and build the project, sometimes I cannot see any behaviors in assets. And sometimes I see only few of them, not all. But I see them, when I create new WPF project in VS 2008, add references from there, build it there and open it in Blend 3. I was also trying to follow this tutorial to create my own behavior, but after I've done exactly the same steps as in the tutorial and built the project, my behavior didn't showed up in assets library. I tried building it in both Blend and VS 2008, and then reloading it in Blend, but the behavior still didn't showed up.

    2.) So, my behavior didn't showed up in assets, so I tried to add it manually directly into XAML code. I was surprised with the error that Blend showed. The errors were "Namespace prefix "i" is not defined." and "Interaction is not supported in a Windows Presentation Foundation (WPF) project." Or is it true that WPF projects doesn't support interaction? Here is a screenshot of my code and the errors:

     

    3.) The last and biggest problem is, that when I lastly see any behaviors, (but till now, my own behaviors never showed up) and try to drop them on any object in the design view, Blend 3 crashes on an unhandled NullReferenceException . This is most frequently, but I also managed to invoke unhandled InvalidCastException , also by trying to drop any of the Microsoft.Expression.Interaction behaviors on an object. Please, help me figure this out. If you need any additional information, just say what exactly.

    Here are screenshots of the errors:

    NullReferenceException:




    InvalidCastException:




    Thank you in advance for any help.
    - Bc. Peter Javorský
    Wednesday, May 27, 2009 12:37 PM

All replies

  • So I figured out the "Namespace prefix "i" is not defined." and "Interaction is not supported in a Windows Presentation Foundation (WPF) project." problem.

    I just had to add
    xmlns:i="http://schemas.microsoft.com/expression/2009/interactivity"
    in the XAML code.

    But Blend 3 still gives me errors: "The namespace prefix "local" is not defined." and "SimpleSample is not supported in a Windows Presentation Foundation (WPF) project."

    The SimpleSample.cs code is here:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;
    using Microsoft.Expression.Interactivity;
    
    namespace behaviors_test
    {
    	 public class SimpleSampleAction: Microsoft.Expression.Interactivity.Behavior<Button>
    	 {
             protected override void OnAttached()
             {
                 this.AssociatedObject.Click += this.AssociatedObject_Click;
             }
    
             protected override void OnDetaching()
             {
                 this.AssociatedObject.Click -= this.AssociatedObject_Click;
             }
             
             private void AssociatedObject_Click(object sender, System.Windows.RoutedEventArgs e)
    		 {
    		    MessageBox.Show("Hello World!");
    		 } 
    
    	}
    	
    	
    	public class SimpleSampleAction_TargetedTrigger: TargetedTriggerAction<FrameworkElement>
    	{
    		protected override void Invoke(object parameter)
    		{
    			if (Target == null) return;
    			MessageBox.Show("Hello World!");
    		}
    	}
    }


    Any ideas?
    Wednesday, May 27, 2009 1:02 PM
  • Peter,

    It sounds like you're having a couple problems.  First, the error with SimpleSampleAction.  You need to define the local prefix in your XAML file.  This can be done with:
       xmlns:local="clr-namespace:AssemblyName"
    Where "AssemblyName" is probably going to be "behaviors_test2" in your case.

    The crashes you're seeing are a bit harder to diagnose.  However, it sounds a bit similar to problems I've seen elsewhere.  Try this: 
     - Go to the Blend project pane and expand the References folder
     - Hover over the Microsoft.Expression.Interactivty.dll reference and check the full path.
     - Is it pointing at the assembly where Blend is installed?  Or a copy of that assembly in your project (or elsewhere)? 
    Elaborating on the last point, you really want your project referencing the assembly in the Blend install directory.  If you find it is pointing at something different, you should use the project pane to remove the assembly reference (available in the RMB popup menu).  Then you can use the RMB menu option to add an assembly reference and browse to the Blend install.  This is probably worth doing even if it looks like it is pointing at the right thing- the Blend add assembly reference command does something slightly different than the Visual Studio equivalent.  In this particular case, the Blend option is probably what you want.  If this doesn't work, I'll need more information to figure out the problem.  The easiest thing to do is share out your project. 

    As a final note- we are aware that setting up Blend projects to enable Behaviors is a weakness in the MIX preview.  We're trying to improve this greatly for the final product.

    Thanks,
    Currier

    Saturday, May 30, 2009 1:19 AM
  • Hi Currier,
    many thanks for your reply. I added xmlns:local="clr-namespace:behaviors_test2" to my xaml, but I'm still getting this error:

    The specified value cannot be assigned to the collection. the following type was expected: "Behavior".

    You said I should share my project. So here it is.
    As for the crashes, I checked the location of my Microsoft.Expression.Interactivity.dll and it's the right one. I used another one before, but it didn't work either. It still keeps crashing.
    And I see different behaviors in the assest panel each time I run this same project in Blend. I see only 4 or 5 of them, and they're different each time.
    Tuesday, June 2, 2009 10:55 PM
  • Hi Peter,

    We can help you out with this. If you wanted quicker responses, could you please get in touch with me offline at unnir at microsoft dot com?

    One thing that would help is the call stack that you get when Blend crashes. To get that, launch Blend from the command prompt as follows: Blend.exe /ExceptionLog

    Then when Blend crashes, you get a Notepad instance with the call stack trace in it. That will help us narrow down the problem.

    Thanks,
    Unni
    Wednesday, June 3, 2009 6:45 PM
    Moderator