I am attempting to serialize an object for MSMQ.
[2014-09-03 21:45:35,525] caught Exception: ToString(): System.InvalidOperationException: There was an error reflecting type 'foo.bar.graphics.ConnectionVisual3D'. ---> System.InvalidOperationException: There was an error reflecting property 'Tube'. ---> System.InvalidOperationException: There was an error reflecting type 'HelixToolkit.Wpf.TubeVisual3D'. ---> System.InvalidOperationException: Cannot serialize member 'HelixToolkit.Wpf.ExtrudedVisual3D.TextureCoordinates' of type 'System.Collections.Generic.IList1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]', see inner exception for more details. ---> System.NotSupportedException: Cannot serialize member HelixToolkit.Wpf.ExtrudedVisual3D.TextureCoordinates of type System.Collections.Generic.IList
1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] because it is an interface.
[...]
I'm using XMLFormatter, like I usually do, but this is the first time I have had trouble with objects within objects, and the errors are pointing toward the helix source, as in:
System.NotSupportedException: Cannot serialize member HelixToolkit.Wpf.ExtrudedVisual3D.TextureCoordinates of type System.Collections.Generic.IList`1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] because it is an interface.
I read that yuo can sometimes supply the formatter with the classes to use (see immediately below), but this complaint is because it apparently is being told to serialize an Interface...
[C# example from http://stackoverflow.com/questions/25559897/serialize-deserialize-a-dynamic-object]
static bool Save(Animal animal)
{
var lListOfAnimals = (from lAssembly in AppDomain.CurrentDomain.GetAssemblies()
from lType in lAssembly.GetTypes()
where typeof(Animal).IsAssignableFrom(lType)
select lType).ToArray();
System.Xml.Serialization.XmlSerializer ListSer = new System.Xml.Serialization.XmlSerializer(typeof(Animal), lListOfAnimals);
[code:]
Me.TheQ = New MessageQueue(qPath)
'
' Create a new message.
'
Me.MsgTo = New Message(connectionEntry, New XmlMessageFormatter(New Type() {GetType(bar.graphics.ConnectionVisual3D)}))
With Me.MsgTo
.AcknowledgeType = AcknowledgeTypes.PositiveReceive Or AcknowledgeTypes.PositiveArrival
.Priority = MessagePriority.Normal
End With
'
' set what will be sent with message... overrides queue defaults (if different)...
'
TheQ.MessageReadPropertyFilter.ArrivedTime = True
TheQ.MessageReadPropertyFilter.SentTime = True
TheQ.MessageReadPropertyFilter.CorrelationId = True
TheQ.MessageReadPropertyFilter.Id = True
TheQ.Formatter = New XmlMessageFormatter(New Type() {GetType(bar.graphics.ConnectionVisual3D)})
'
' Send the event to the queue.
'
TheQ.Send(MsgTo)
Public Class ConnectionVisual3D
Inherits ModelVisual3D
Implements INotifyPropertyChanged
[...]
Public Property Tube As TubeVisual3D
Get
Return _tube
End Get
Set(value As TubeVisual3D)
'If Not value.Equals(_tube) Then
_tube = value
RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("Tube"))
'End If
End Set
End Property
...so inside ConnectionVisual3D there are objects like the TubeVisual3D.
Full trace:
[2014-09-03 21:45:30,883] caught Exception: ToString(): System.InvalidOperationException: There was an error reflecting type 'foo.bar.graphics.ConnectionVisual3D'. ---> System.InvalidOperationException: There was an error reflecting property 'Tube'. ---> System.InvalidOperationException: There was an error reflecting type 'HelixToolkit.Wpf.TubeVisual3D'. ---> System.InvalidOperationException: Cannot serialize member 'HelixToolkit.Wpf.ExtrudedVisual3D.TextureCoordinates' of type 'System.Collections.Generic.IList1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]', see inner exception for more details. ---> System.NotSupportedException: Cannot serialize member HelixToolkit.Wpf.ExtrudedVisual3D.TextureCoordinates of type System.Collections.Generic.IList
1[[System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] because it is an interface.
--- End of inner exception stack trace ---
at System.Xml.Serialization.StructModel.CheckSupportedMember(TypeDesc typeDesc, MemberInfo member, Type type)
at System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo propertyInfo)
at System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo memberInfo)
at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.ImportAccessorMapping(MemberMapping accessor, FieldModel model, XmlAttributes a, String ns, Type choiceIdentifierType, Boolean rpc, Boolean openModel, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.ImportFieldMapping(StructModel parent, FieldModel model, XmlAttributes a, String ns, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlReflectionImporter.InitializeStructMembers(StructMapping mapping, StructModel model, Boolean openModel, String typeName, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns, Boolean openModel, XmlAttributes a, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, XmlAttributes a, Boolean repeats, Boolean openModel, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.ImportElement(TypeModel model, XmlRootAttribute root, String defaultNamespace, RecursionLimiter limiter)
at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type, XmlRootAttribute root, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Messaging.XmlMessageFormatter.Write(Message message, Object obj)
at System.Messaging.Message.AdjustToSend()
at System.Messaging.MessageQueue.SendInternal(Object obj, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)
at System.Messaging.MessageQueue.Send(Object obj)
at foo.bar.messaging.ConnV3DQueue.SendMessage(ConnectionVisual3D connectionEntry, String qPath) in D:\Repositories\fooRedmine\v1\foo_v1\bar\messaging\ConnV3DQueue.vb:line 174, Last Milliseconds: 13.0008 [FATAL] Machine: DOOZY User: Pat Process: 53 CallingMethod: foo.bar.messaging.ConnV3DQueue.SendMessage LineNumber: 194
Is this something that source can resolve, or do I need to go about serialization completely differently?