I'm still having continuous difficulties getting Json.Net and NHibernate to play nicely together. Namely, in getting Json.NET to serialize a proxied NHibernate object.
I've followed the recommendations here, both for the accepted answer and the ammendments, but no dice.
The biggest problem with the above solution is that it seems that modern versions of NHibernate are using the INHibernateProxyProxy
interface to create proxies (rather than INHibernateProxy? Can anyne else confirm this?), whose base class in my case is NHibernate.Proxy.DynamicProxy.ProxyDummy
, which reveals nothing about the underlying object when I attempt to create the Json constract using my custom scontract resolver, ie:
protected override JsonContract CreateContract(Type objectType)
{
if (typeof(NHibernate.Proxy.INHibernateProxy).IsAssignableFrom(objectType))
return base.CreateContract(objectType.BaseType);
else
return base.CreateContract(objectType);
}
Does anyone have any advice for how to deal with INHibernateProxyProxy
effectively?