0

I am using a netdatacontractserializer and a SerializationBinder to create my own runtime types for nhibernate proxies on the client side.

This all works except I am forced to assume that there is only one type by each name in the domain model. i.e. i am forced to ignore the namespace. The reason is that SerializationBinder only gives me access to "MyObjectProxyb04bae2d04d34e8a98b1d93bf24428cc" and "DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" to derive the parent tyep.

As you can see there is no data that points to the namespace of the parent type.

I have had a look at changing the name of the generated proxy (to include a namespace prefix) but that seems to be hard coded.

Simon
  • 33,714
  • 21
  • 133
  • 202
  • I think some details about why you are trying to change the class name of the proxy object would be useful. – Sean Carpenter Feb 24 '09 at 01:06
  • Please post another question: "How can I find out the proxied type for a DynamicProxy proxy?", this has become quite unrelated to the original question after the edits. – Mauricio Scheffer Feb 24 '09 at 13:48
  • mausch good point. I have reworded the question. – Simon Feb 24 '09 at 20:54
  • It looks that you'll have to make 2 or 3 *specific* questions out of this one to answer your whole problem... otherwise this question will keep changing and the answers will change too, to the frustration of everyone. – Mauricio Scheffer Feb 25 '09 at 02:30
  • The proxying question has already been answered, now post another question for the serialization part. Please don't delete or change this question further as it could serve for future reference. – Mauricio Scheffer Feb 25 '09 at 02:32

1 Answers1

2

You can cast the proxy to INHibernateProxy and get the persistent underlying class:

((INHibernateProxy)proxy).HibernateLazyInitializer.PersistentClass
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275