Dispatcher Exception RRS feed

  • Question

  • I have a Silverlight UserControl that tries to do this
    Or this
    Both produce a NullReferenceException trying get the Dispatcher.

    Of course, this all works fine in the Browser but not in Blend 2.5.

    Any fixes/alternatives?
    • Edited by ray440 Monday, September 15, 2008 10:52 PM
    Monday, September 15, 2008 10:50 PM

All replies

  • I have the same problem, and wrapping the Dispatcher line in a try/catch clause has no impact.

    At runtime and in VS 2008, it works fine. In the Blend design view, I get:

    Method not found: "System.Windows.Threading.DispatcherOperation  System.Windows.Threading.Dispatcher.BeginInvoke(System.Action)"
    Wednesday, January 7, 2009 11:44 PM
  • This code causes Blend to fail when setting the property:
    var x = 2;  
    if (x == 1)  

    but this is won't:

    if (false)  

    What is going on?  Is Blend checking this code independant of the runtime and tripping over BeginInvoke??

    Tuesday, January 13, 2009 1:26 AM
  •  Hi Glen-
    I'm looking into this bug and my only guess is that for some reason you're picking up older or outdated versions of Silverlight. Could you verify that you are on Blend 2 SP1 and Silverlight 2 RTM? If you used any previous builds of Silverlight you might want to try reinstalling the Silverlight SDK to make sure everything is updated properly.

    This code should be running inside of Blend against the Silverlight runtime assemblies, we don't do any additional validation or processing of the code.

    It is important to note that when running inside of Blend or Visual Studio the Dispatcher.BeginInvoke method will silently fail but it should not throw an exception.

    Pete Blois
    PM, Expression Blend
    Wednesday, January 14, 2009 10:52 PM
  • Thanks for the updates Pete!

    I'll check, and reply in the Connect feedback. Once resolved, this thread can be updated.

    Wednesday, January 14, 2009 10:55 PM
  • I do have Expression Blend 2 Service Pack 1   Version 2.1.1760.0

    For Silverlight, the "Add or Remove Programs" in Control Panel shows that I have:
    - Microsoft Silverlight
          "Support Information" for the first entry shows version 2.0.31005.0

    - Microsoft Silverlight 2 SDK
    - Microsoft Silverlight Tools for Visual Studio 2008 SP1 - ENU
    Under "C:\Program Files\Microsoft Silverlight", I have a single folder called "2.0.31005.0"

    I re-downloaded the SDK and ran install, choosing to Repair the installation.

    After, I opened Blend and still have the same issues.

    Is there anything I missed there?

    Wednesday, January 14, 2009 11:35 PM
  • Could you take a look at the version number of System.Windows.dll in C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies?

    Blend and Visual Studio both pick up their Silverlight assemblies from this location. The assemblies should be identical to the Silverlight 2 RTM bits (this folder is here to allow tooling to target Silverlight 2 after your browser version has been updated).

    If the file version of the assembly is incorrect I'd suggest deleting the entire folder of C:\Program Files\Microsoft SDKs\Silverlight and re-install the SDK.

    Wednesday, January 14, 2009 11:44 PM
  • Guess I replied in here, not Connect. Oh well...

    Version number under SDKs... 2.0.31005.0

    I did a sweep of my drive, and found two main copies of System.Windows.dll  - in the Silverlight and SDKs folders. It also found copies of those in some temp folders and in my project folders. All are at the same version number, file size, etc.

    • Edited by Glen Little Thursday, January 15, 2009 12:24 AM Found more than 2 copies...
    Thursday, January 15, 2009 12:11 AM
  • I'm running out of ideas fast. Does this happen only for this project or for all projects? If it's limited to a specific project, would it be possible to attach it to the connect bug?


    Thursday, January 15, 2009 12:36 AM
  • We'll try to make a simple sample...
    Thursday, January 15, 2009 1:17 AM