5

I Just upgraded my SL4 application to SL5. I downloaded the MVVM light toolkit source for SL 5 and build it: http://mvvmlight.codeplex.com/SourceControl/changeset/changes/17256019ad97

Initially everything works fine, but the GalaSoft messaging is somehow broken. The Message is sent, but never picked up by the receiver (using Messenger.Default.Register). No build warnings/errors and no errors in the output window.

Is anyone aware of any breaking changes in relation to new MVVM Light SL5 update?

/Thomas

Jehof
  • 34,674
  • 10
  • 123
  • 155
  • 3
    Can you please send me a repro at laurent (at) galasoft (dot) ch, I want to investigate. Thanks! – LBugnion Dec 16 '11 at 10:11
  • I'm using the latest MVVM light 3 from the installer with Silverlight 5, and messaging still works, so it must come from your setup. – jv42 Dec 21 '11 at 11:17
  • The only seen I've seen broken was in `RaisePropertyChanged()`, but that was documented on @LBugnion's blog. – jv42 Dec 21 '11 at 11:17
  • You probably shouldn't be using them anyways. There are plenty of alternatives (parent-child, shared model, shared view-model) that are easier to understand and far less prone to leaking memory. – Jonathan Allen Jan 14 '12 at 05:52

1 Answers1

0

I've had the same thing happen to me when upgrading from an older version of MVVM Light (change set 3bdbffb4e70a “BL0014 Misc”). Instantly Send() stopped working.

To resolve the issue try using using the .Register() overload with receiveDerivedMessagesToo set to true.

This issue can happen when Send()ing objects which have some type of DynamicProxy created for them. For example EntityFramework will do this when you use the Local property under any of the collections of your data context.

e.g. EntityFramework DBContext for ctx.Dealers.Local will generate a list of items of type that look like: System.Data.Entity.DynamicProxies.Dealer_D4CEAA0F527F5360DEB9B2B35305241B76A107C37B9DB8B368984B7DF69AEE1E

When matching to Registered Listeners Messenger.SendToTargetOrType() will fail since the Registered Type is just a "Dealer" and not a Proxy of the dealer.

Why did this used to work without requiring receiveDerivedMessagesToo set to true and it doesn't now?

Previously MVVM Light "Messenger.cs" Messenger.SendToTargetOrType() had this code:

private void SendToTargetOrType<TMessage>(TMessage message, Type messageTargetType, object token) 
{ 
  var messageType = typeof(TMessage); 

This worked great since the actual type of the data being passed did not matter, just the type of the registed type.

Now the code has been changed to:

private void SendToTargetOrType<TMessage>(TMessage message, Type messageTargetType, object token)
{
  Type messageType = message.GetType();

Now the Type of the parameter is being used instead. This is a problem since if your "message" is of some type of proxy the search of Registed listeners will fail.

Tolga
  • 2,643
  • 1
  • 27
  • 18