There are many reasons for this exception to pop up especially if you are using the Lazy initialization feature of NHibernate.
I had simple bi-directionally mapped one to many relationship (Error - Error Details). Nhibernate was not throwing any exceptions during the loading of a List of Errors, but WCF was complaining about a type mismatch when trying to serialize the list of Errors. [Note. I have reference preserving custom datacontract serializer implemented that works fine.]
This made me look into the actual list which WCF is trying to serialize, then only i noticed that the Error Details collection was full of this "illegal access...." exception.
couple of hours of googling brought me nothing as various articles suggested, setting inverse true, setting access attribute, orphaned records in the database etc. where none of these was the reason for mine, but please note that these can also be the cause for this exception so do not rule them out.
Finally mine was due to a type mis -match in the Error Details mapping, in the hbm file, so if none of the above solves your problem take a second look at you hbm file mappings that can be the culprit in your case.
Tuesday, March 22, 2011
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment