Print Page | Close Window

IEntityLoginManager Serialization Issues

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1936
Printed Date: 21-Apr-2026 at 8:39pm


Topic: IEntityLoginManager Serialization Issues
Posted By: midnit
Subject: IEntityLoginManager Serialization Issues
Date Posted: 02-Jul-2010 at 9:39am
We are working on upgrading to DevForce 2010. Our IEntityLoginManager worked fine in 2009 and I expect is not the issue here but I am at a loss at what IS causing the issue. Please advise.
 
"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://ideablade.com/EntityModel:LoginResult - http://ideablade.com/EntityModel:LoginResult . The InnerException message was 'Element 'http://ideablade.com/EntityModel:Principal' contains data of the 'http://schemas.datacontract.org/2004/07/System.Security.Principal:GenericPrincipal' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'GenericPrincipal' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details."



Replies:
Posted By: ting
Date Posted: 02-Jul-2010 at 8:26pm

We made a change to the IEntityLoginManager in DevForce 2010 (this was buried on page 28 of the Release Notes).  You should now be returning a UserBase or your own IPrincipal.  As Kim writes below, GenericPrincipal and GenericIdentity are not native to Silverlight and we no longer define them.

If you subclass from UserBase make sure to mark any properties you need on the client with the [DataMember] attribute so they will serialize.
 
If you implement your own IPrinicpal, you can make it serializable by doing the following:
  1. Have the class "implement" the IKnownType interface.  (This is a marker interface, so no actual implementation is required.)
  2. Mark the class with the [DataContract] attribute
  3. Mark each serializable property with the [DataMember] attribute.

 



Posted By: kimj
Date Posted: 04-Jul-2010 at 6:01pm
GenericPrincipal and GenericIdentity are not types intrinsic to Silverlight.  In DevForce Silverlight 2009 we did define these types within the DF assemblies, but we dropped this in DF 2010.  (GenericPrincipal and GenericIdentity are still available in standard .NET - http://msdn.microsoft.com/en-us/library/system.security.principal.genericprincipal.aspx - http://msdn.microsoft.com/en-us/library/system.security.principal.genericprincipal.aspx .) 
 
You can return any type implementing IPrincipal from an IEntityLoginManager, as long as it's defined on both client and server.


Posted By: mlens
Date Posted: 29-Jul-2010 at 5:23pm
Any chance you could post a sample implementation of the LoginManager under DevForce 2010? It's really confusing when you say GenericPrincipal and GenericIdentity are no longer supported but the login method of IEntityLoginManager returns IPrincipal....

Thanks


Posted By: kimj
Date Posted: 30-Jul-2010 at 10:30am
There's a snippet here, along with more information  -
http://www.ideablade.com:8989/xwiki/bin/view/Documentation/Security#HImplementingIEntityLoginManager - http://www.ideablade.com:8989/xwiki/bin/view/Documentation/Security#HImplementingIEntityLoginManager
 



Print Page | Close Window