SerializationException with custom GenericIdentiy?

Posted by MunkiPhD on Stack Overflow See other posts from Stack Overflow or by MunkiPhD
Published on 2009-09-14T03:19:21Z Indexed on 2010/03/17 22:41 UTC
Read the original article Hit count: 357

I'm trying to implement my own GenericIdentity implementation but keep receiving the following error when it attempts to load the views (I'm using asp.net MVC):

 System.Runtime.Serialization.SerializationException was unhandled 
 by user code Message="Type is not resolved for member 
 'OpenIDExtendedIdentity,Training.Web, Version=1.0.0.0, 
 Culture=neutral, PublicKeyToken=null'."
      Source="WebDev.WebHost"

I've ended up with the following class:

[Serializable]
    public class OpenIDExtendedIdentity : GenericIdentity {
        private string _nickName;
        private int _userId;

        public OpenIDExtendedIdentity(String name, string nickName, int userId)
            : base(name, "OpenID") {
            _nickName = nickName;
            _userId = userId;
        }
        public string NickName {
            get { return _nickName; }
        }

        public  int UserID {
            get { return _userId; }
        }
    }

In my Global.asax I read a cookie's serialized value into a memory stream and then use that to create my OpenIDExtendedIdentity object. I ended up with this attempt at a solution after countless tries of various sorts. It works correctly up until the point where it attempts to render the views.

What I'm essentially attempting to achieve is the ability to do the following (While using the default Role manager from asp.net):

User.Identity.UserID
User.Identity.NickName
... etc.

I've listed some of the sources I've read in my attempt to get this resolved. Some people have reported a Cassini error, but it seems like others have had success implementing this type of custom functionality - thus a boggling of my mind.

© Stack Overflow or respective owner

Related posts about genericidentity

Related posts about asp.net-mvc