-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: serializing ISet for domain object transfer in web service
PostPosted: Tue Oct 18, 2005 4:06 pm 
Newbie

Joined: Tue Oct 18, 2005 3:55 pm
Posts: 1
I have a WinForms fat client application backed by a ASP.NET WebService. I would like to do my data access with NHibernate in the web service. However, when I try to serialize my domain object through the web service, I get the exception:

"You must implement a default accessor on Iesi.Collections.ISet because it inherits from ICollection."

I believe I'm using NHibernate correctly. My application works when I run it all in one process (directly call the object loading code without a web service wrapper). I recognize that ISet doesn't declare the default indexer (object this[object key] { get; set; }) because it is trying to provide set semantics. However, I believe that this accessor should be added to ISet to support serialization.

Does this sound correct? Is there anything I'm doing wrong? I've included the stack trace below for reference.

Aaron

[InvalidOperationException: You must implement a default accessor on Iesi.Collections.ISet because it inherits from ICollection.]
System.Xml.Serialization.TypeScope.GetCollectionElementType(Type type) +580
System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, Boolean canBePrimitive, MemberInfo memberInfo) +549
System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference) +50
System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo propertyInfo) +57
System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo memberInfo) +88
System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns) +1532
System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, Boolean repeats) +440


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 4:08 pm 
Beginner
Beginner

Joined: Wed Jun 01, 2005 3:22 pm
Posts: 38
Location: Menlo Park, CA
I just cheated.

I did
Code:
[XmlIgnore]
public ISet RealProperty

[...]

[XmlElement("RealProperty")]
public ArrayList RealPropertyCopyWrapper
{
     get
     {
          return new ArrayList(RealProperty);
     }
     set
     {
         RealProperty.Clear();
         RealProperty.AddAll(value);
     }
}


Top
 Profile  
 
 Post subject: thats good
PostPosted: Tue Oct 25, 2005 3:51 pm 
I did much the same and I think that is a good solution.

However, for some situations I am using classes that I cannot change. I have tried things like extending the class, overriding the property and adding XMLIgnore on the overridden one, but that doesn't seem to work. I still get the same error message.


Top
  
 
 Post subject:
PostPosted: Tue Oct 25, 2005 6:26 pm 
Beginner
Beginner

Joined: Wed Jun 01, 2005 3:22 pm
Posts: 38
Location: Menlo Park, CA
In those cases you might have to break down and implement IXMLSerializable and serialize the properties which are classes you can't change manually. Quite tedious, but doable.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.