Hey Folks,
I have an interesting problem here. I get the error message "Member 'StudentID' of class 'BCL.BusinessObjects.EventWrapper' cannot use element name 'StudentID' because it is already being used by member 'StudentID'." when I try to serialize an EventWrapper object. I found this issue: https://jira.mongodb.org/browse/CSHARP-180 (“Misleading exception message”) that suggests it’s due to a duplicate BsonElement name anywhere in the class.
The thing is, the class doesn’t have any [BsonElement] attributes anywhere. None in the classes it contains, either. And the class is in a Silverlight assembly, so I can’t reference the Mongo assemblies to put in any BsonElement attributes.
Help me Obi Wan Kenobi, you’re my only hope!
Dan Terrill
Chief Development Engineer
C8 Sciences
5 Science Park
New Haven, CT 06511
Ok, I’ve figured out the problem. It seems the EventWrapper class inherited from a base class and hid some of its properties. The serializer must have gotten confused.
You can reproduce it like this:
public class BaseClass
{
public Guid ID { get; set; }
}
public class DerivedClass : BaseClass
{
public Guid ID { get; set; }
}
A temporary fix was to remove the inheritance. That’s not good long-term, though. Any idea how I can work around it?
--
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com.
To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.