I've been testing out Glimpse on a cross-platform prototype which uses MVVM for various front ends (MVC3, WPF4, WP7) and appear to have run into issues with Glimpse in MVC3 due to Json.NET serialization woes. Glimpse is working fine for views not using MVVM.
Using MVVMLight v3.0.3, Autofac for DI v2.5.2 and Glimpse v0.86.
Here's the Glimpse log:
2011-12-14 11:23:39.9096|INFO|Glimpse.Core.Module|BeginRequest handling complete for requestId 2e9285ee-a2ac-44fe-bd26-e85fb2f83b1b (/)| 2011-12-14 11:23:39.9096|WARN|Glimpse.Mvc3.Plugin.Execution|get_Binders method of System.Web.Mvc.ControllerActionInvoker type is not proxyable.| 2011-12-14 11:23:39.9096|WARN|Glimpse.Mvc3.Plugin.Execution|set_Binders method of System.Web.Mvc.ControllerActionInvoker type is not proxyable.| 2011-12-14 11:23:39.9096|WARN|Glimpse.Mvc3.Plugin.Execution|GetType method of System.Web.Mvc.ControllerActionInvoker type is not proxyable.| 2011-12-14 11:23:39.9096|WARN|Glimpse.Mvc3.Plugin.Execution|MemberwiseClone method of System.Web.Mvc.ControllerActionInvoker type is not proxyable.| 2011-12-14 11:23:39.9356|INFO|Glimpse.Core.Module|PostRequestHandlerExecute handling complete for requestId 2e9285ee-a2ac-44fe-bd26-e85fb2f83b1b (/)| 2011-12-14 11:23:39.9356|INFO|Glimpse.Core.Module|PostReleaseRequestState handling complete for requestId 2e9285ee-a2ac-44fe-bd26-e85fb2f83b1b (/)| 2011-12-14 11:23:39.9576|WARN|Glimpse.Core.Plumbing.GlimpseSerializer|Serializer error|System.NotSupportedException--'CommandConverter' is unable to convert 'GalaSoft.MvvmLight.Command.RelayCommand' to 'System.String'.-- at System.ComponentModel.TypeConverter.GetConvertToException(Object value, Type destinationType) at System.Windows.Input.CommandConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType) at System.ComponentModel.TypeConverter.ConvertToString(ITypeDescriptorContext context, CultureInfo culture, Object value) at System.ComponentModel.TypeConverter.ConvertToInvariantString(Object value) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.TryConvertToString(Object value, Type type, String& s) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeString(JsonWriter writer, Object value, JsonStringContract contract) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContract collectionValueContract) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.WriteMemberInfoProperty(JsonWriter writer, Object memberValue, JsonProperty property, JsonContract contract) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContract collectionValueContract) 2011-12-14 11:23:39.9756|WARN|Glimpse.Core.Plumbing.GlimpseSerializer|Serializer error|Newtonsoft.Json.JsonWriterException--Token PropertyName in state Property would result in an invalid JavaScript object.-- at Newtonsoft.Json.JsonWriter.AutoComplete(JsonToken tokenBeingWritten) at Newtonsoft.Json.JsonWriter.WritePropertyName(String name) at Newtonsoft.Json.JsonTextWriter.WritePropertyName(String name) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.WriteMemberInfoProperty(JsonWriter writer, Object memberValue, JsonProperty property, JsonContract contract) at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContract collectionValueContract) ... et cetera
For the NotSupportedException
I tried marking the associated model/view model fields [NonSerialized]
and properties with [JsonIgnore]
or [ScriptIgnore]
to no avail, as CommandConverter
appears to be the sticking point, since RelayCommand
implements ICommand
:
[TypeConverter("System.Windows.Input.CommandConverter, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null"), ValueSerializer("System.Windows.Input.CommandValueSerializer, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Custom=null")]
public interface ICommand
Anyone know how to get around that?
Also, I'm at a loss to explain the JsonWriterException
: Token PropertyName in state Property would result in an invalid JavaScript object, and it seems other people are too.
Does anyone know what token X and state X refer to?