<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Sending NHibernate entities over the WCF wire</title>
	<atom:link href="http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/feed/" rel="self" type="application/rss+xml" />
	<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/</link>
	<description>Trying to walk that thin line between intelligence and ignorance</description>
	<lastBuildDate>Wed, 17 Mar 2010 18:22:17 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Ganesh</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-23099</link>
		<dc:creator>Ganesh</dc:creator>
		<pubDate>Mon, 07 Dec 2009 05:42:55 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-23099</guid>
		<description>Hello,
    I made silverlight 3 + Silverlight enabled WCF service + NHibenate application.
   I write two contract methods. First contract methods works fine .. but when I call second method it gives me exception that &quot;The remote server returned an error: NotFound.&quot; in referance.cs fil..
  why this happened ..
  pls help me.. I spend a lot time to solve this problem ..</description>
		<content:encoded><![CDATA[<p>Hello,<br />
    I made silverlight 3 + Silverlight enabled WCF service + NHibenate application.<br />
   I write two contract methods. First contract methods works fine .. but when I call second method it gives me exception that &#8220;The remote server returned an error: NotFound.&#8221; in referance.cs fil..<br />
  why this happened ..<br />
  pls help me.. I spend a lot time to solve this problem ..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: staticage</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-22799</link>
		<dc:creator>staticage</dc:creator>
		<pubDate>Fri, 23 Oct 2009 09:40:45 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-22799</guid>
		<description>Nice! Thanks a lot.</description>
		<content:encoded><![CDATA[<p>Nice! Thanks a lot.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gaurav</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-21388</link>
		<dc:creator>Gaurav</dc:creator>
		<pubDate>Tue, 30 Jun 2009 09:59:56 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-21388</guid>
		<description>Hi,

I am trying to access the WCF service having following interface and implementation:

[ServiceContract(Namespace=&quot;http://SMS.com/OPS&quot;)]
public interface IOrderProcessingService
{
    [UseNetDataContractSerializer]
    [OperationContract]
    Customer GetAnyCustomer();

    [UseNetDataContractSerializer]
    [OperationContract]
    Customer GetCustomerByName(string customerName);
}

public class OrderProcessingService : IOrderProcessingService
{
    public Customer GetAnyCustomer()
    {
       ICustomerRepository repository = new CustomerRepository();
       return repository.GetByName(&quot;Tom&quot;);
    }

    public Customer GetCustomerByName(string customerName)
    {
      	ICustomerRepository repository = new CustomerRepository();
        return repository.GetByName(customerName);
            
    }    	
}

CustomerRepository class is accessing the database using NHibernate.

Now the problem is that the method GetAnyCustomer() is working fine. But when the service client is accessing the method GetCustomerByName, the following exception is thrown, indicating that there is some problem in deserializing the given string parameter customerName. The exception details are as follows:

WorkingWithGraph.Tests.OrderProcessingServiceTest.GetCustomerByNameTest : System.ServiceModel.FaultException : The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://SMS.com/OPS:customerName. The InnerException message was &#039;Error in line 1 position 281. XML &#039;Element&#039; &#039;http://SMS.com/OPS:customerName&#039; does not contain expected attribute &#039;http://schemas.microsoft.com/2003/10/Serialization/:Type&#039;. The deserializer has no knowledge of which type to deserialize. Check that the type being serialized has the same contract as the type being deserialized.&#039;.  Please see InnerException for more details.

And what does it meant by : XML &#039;Element&#039; &#039;http://SMS.com/OPS:customerName&#039; does not contain expected attribute &#039;http://schemas.microsoft.com/2003/10/Serialization/:Type&#039;

I have also tried encapsulating the customerName both in a DataContract and in a MessageContract and used these contracts as parameter types, but not to avail anything.

Please help me.

Thanks in advance.
Gaurav</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I am trying to access the WCF service having following interface and implementation:</p>
<p>[ServiceContract(Namespace="http://SMS.com/OPS")]<br />
public interface IOrderProcessingService<br />
{<br />
    [UseNetDataContractSerializer]<br />
    [OperationContract]<br />
    Customer GetAnyCustomer();</p>
<p>    [UseNetDataContractSerializer]<br />
    [OperationContract]<br />
    Customer GetCustomerByName(string customerName);<br />
}</p>
<p>public class OrderProcessingService : IOrderProcessingService<br />
{<br />
    public Customer GetAnyCustomer()<br />
    {<br />
       ICustomerRepository repository = new CustomerRepository();<br />
       return repository.GetByName(&#8220;Tom&#8221;);<br />
    }</p>
<p>    public Customer GetCustomerByName(string customerName)<br />
    {<br />
      	ICustomerRepository repository = new CustomerRepository();<br />
        return repository.GetByName(customerName);</p>
<p>    }<br />
}</p>
<p>CustomerRepository class is accessing the database using NHibernate.</p>
<p>Now the problem is that the method GetAnyCustomer() is working fine. But when the service client is accessing the method GetCustomerByName, the following exception is thrown, indicating that there is some problem in deserializing the given string parameter customerName. The exception details are as follows:</p>
<p>WorkingWithGraph.Tests.OrderProcessingServiceTest.GetCustomerByNameTest : System.ServiceModel.FaultException : The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter <a href="http://SMS.com/OPS:customerName" rel="nofollow">http://SMS.com/OPS:customerName</a>. The InnerException message was &#8216;Error in line 1 position 281. XML &#8216;Element&#8217; &#8216;http://SMS.com/OPS:customerName&#8217; does not contain expected attribute &#8216;http://schemas.microsoft.com/2003/10/Serialization/:Type&#8217;. The deserializer has no knowledge of which type to deserialize. Check that the type being serialized has the same contract as the type being deserialized.&#8217;.  Please see InnerException for more details.</p>
<p>And what does it meant by : XML &#8216;Element&#8217; &#8216;http://SMS.com/OPS:customerName&#8217; does not contain expected attribute &#8216;http://schemas.microsoft.com/2003/10/Serialization/:Type&#8217;</p>
<p>I have also tried encapsulating the customerName both in a DataContract and in a MessageContract and used these contracts as parameter types, but not to avail anything.</p>
<p>Please help me.</p>
<p>Thanks in advance.<br />
Gaurav</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-11712</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Wed, 08 Apr 2009 18:18:32 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-11712</guid>
		<description>Somebody else gave me the same advice. It seems to be the way to go. It costs a SELECT but I guess it&#039;s not too much of an issue, and NHibernate makes it real easy anyway.

Thanks a lot !</description>
		<content:encoded><![CDATA[<p>Somebody else gave me the same advice. It seems to be the way to go. It costs a SELECT but I guess it&#8217;s not too much of an issue, and NHibernate makes it real easy anyway.</p>
<p>Thanks a lot !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-11571</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Tue, 07 Apr 2009 14:50:24 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-11571</guid>
		<description>when you get back into your service layer, just retrieve the object from the database again and modify the properties you need/want to update</description>
		<content:encoded><![CDATA[<p>when you get back into your service layer, just retrieve the object from the database again and modify the properties you need/want to update</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-11570</link>
		<dc:creator>Sam</dc:creator>
		<pubDate>Tue, 07 Apr 2009 14:34:08 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-11570</guid>
		<description>Davy &gt; I&#039;m thinking about using DTO&#039;s too because I&#039;m getting totally frustrated with sending my entities over the wire. I have issues with proxy classes and also NH specific types which are not serialized by WCF.

Anyway I wanted to know how you manage to persist your DTO&#039;s to the database with NH ?  I want to do the following :

Load business model entity with NHibernate
Convert business model entity to dto (by just keeping the properties I need)
Client modifies dto and send it back to the server
Server convert dto back to business model entity
NH persists business model entity to database.

But there&#039;s a problem : Since the dto is a smaller version of the business model entity, that means when I re-create my entity on the server side, it&#039;s not going to be a full-feature entity, so how NHibernate is going to figure out what to save ? It&#039;s probably going to interpret that as many properties have changed (when in fact they haven&#039;t) and persists wrong data in the DB.

You insight would be appreciated.</description>
		<content:encoded><![CDATA[<p>Davy &gt; I&#8217;m thinking about using DTO&#8217;s too because I&#8217;m getting totally frustrated with sending my entities over the wire. I have issues with proxy classes and also NH specific types which are not serialized by WCF.</p>
<p>Anyway I wanted to know how you manage to persist your DTO&#8217;s to the database with NH ?  I want to do the following :</p>
<p>Load business model entity with NHibernate<br />
Convert business model entity to dto (by just keeping the properties I need)<br />
Client modifies dto and send it back to the server<br />
Server convert dto back to business model entity<br />
NH persists business model entity to database.</p>
<p>But there&#8217;s a problem : Since the dto is a smaller version of the business model entity, that means when I re-create my entity on the server side, it&#8217;s not going to be a full-feature entity, so how NHibernate is going to figure out what to save ? It&#8217;s probably going to interpret that as many properties have changed (when in fact they haven&#8217;t) and persists wrong data in the DB.</p>
<p>You insight would be appreciated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-9457</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Fri, 06 Mar 2009 14:52:46 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-9457</guid>
		<description>Andres,

i got the same exception sometimes, but i think i only got it when i was hosting the service both through IIS and the Console host... not sure though

either way, this entire approach of sending detached NHibernate entities over WCF is something i no longer recommend... i prefer to keep my NHibernate entities inside the service layer, and send specific DTO&#039;s over WCF</description>
		<content:encoded><![CDATA[<p>Andres,</p>
<p>i got the same exception sometimes, but i think i only got it when i was hosting the service both through IIS and the Console host&#8230; not sure though</p>
<p>either way, this entire approach of sending detached NHibernate entities over WCF is something i no longer recommend&#8230; i prefer to keep my NHibernate entities inside the service layer, and send specific DTO&#8217;s over WCF</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andres</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-9456</link>
		<dc:creator>Andres</dc:creator>
		<pubDate>Fri, 06 Mar 2009 14:35:22 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-9456</guid>
		<description>Al litle more detail, 

the exception occurs when calling

IList customers = proxy.GetCustomersWithTheirOrders();

I debug insîde the Service and it read the information right. ( 1 Order with 2 Lines )

The exception type is System.ArgumentException

The stack Trace is as follows

&quot;\r\nServer stack trace: \r\n   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)\r\n   at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)\r\n   at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck)\r\n   at System.Runtime.Serialization.FormatterServices.SerializationSetValue(MemberInfo fi, Object target, Object value)\r\n   at System.Runtime.Serialization.FormatterServices.PopulateObjectMembers(Object obj, MemberInfo[] members, Object[] data)\r\n   at Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateClassProxy(SerializationInfo info, StreamingContext context)\r\n   at Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateProxy(SerializationInfo info, StreamingContext context)\r\n   at Castle.DynamicProxy.Serialization.ProxyObjectReference..ctor(SerializationInfo info, StreamingContext context)\r\n   at ReadProxyObjectReferenceFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadOrderFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadArrayOfanyTypeFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )\r\n   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadSerializationInfo(XmlReaderDelegator xmlReader, Type type)\r\n   at ReadArrayOfKeyValueOfanyTypeanyTypeFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadCollectionEntryFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadPersistentGenericSetOfOrderSwFpc1QfFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadCustomerFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadArrayOfCustomerFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )\r\n   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadArrayOfCustomerFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.NetDataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)\r\n   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)\r\n   at System.Runtime.Serialization.NetDataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)\r\n   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameter(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc&amp; rpc)\r\n   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc&amp; rpc)\r\n   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)\r\n   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)\r\n   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)\r\n   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\r\n\r\nException rethrown at [0]: \r\n   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)\r\n   at ServiceInterface.ICustomerService.GetCustomersWithTheirOrders()\r\n   at ServiceClient.Program.Main(String[] args) in C:\\Projects\\NHibernate\\WCF\\NhibernateAndWcf\\ServiceClient\\Program.cs:line 16\r\n   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ThreadHelper.ThreadStart()&quot;</description>
		<content:encoded><![CDATA[<p>Al litle more detail, </p>
<p>the exception occurs when calling</p>
<p>IList customers = proxy.GetCustomersWithTheirOrders();</p>
<p>I debug insîde the Service and it read the information right. ( 1 Order with 2 Lines )</p>
<p>The exception type is System.ArgumentException</p>
<p>The stack Trace is as follows</p>
<p>&#8220;\r\nServer stack trace: \r\n   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)\r\n   at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)\r\n   at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck)\r\n   at System.Runtime.Serialization.FormatterServices.SerializationSetValue(MemberInfo fi, Object target, Object value)\r\n   at System.Runtime.Serialization.FormatterServices.PopulateObjectMembers(Object obj, MemberInfo[] members, Object[] data)\r\n   at Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateClassProxy(SerializationInfo info, StreamingContext context)\r\n   at Castle.DynamicProxy.Serialization.ProxyObjectReference.RecreateProxy(SerializationInfo info, StreamingContext context)\r\n   at Castle.DynamicProxy.Serialization.ProxyObjectReference..ctor(SerializationInfo info, StreamingContext context)\r\n   at ReadProxyObjectReferenceFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadOrderFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadArrayOfanyTypeFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )\r\n   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadSerializationInfo(XmlReaderDelegator xmlReader, Type type)\r\n   at ReadArrayOfKeyValueOfanyTypeanyTypeFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadCollectionEntryFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadPersistentGenericSetOfOrderSwFpc1QfFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadCustomerFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadArrayOfCustomerFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString , XmlDictionaryString , CollectionDataContract )\r\n   at System.Runtime.Serialization.CollectionDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, String name, String ns)\r\n   at ReadArrayOfCustomerFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )\r\n   at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserializeInSharedTypeMode(XmlReaderDelegator xmlReader, Int32 declaredTypeID, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.XmlObjectSerializerReadContextComplex.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, String name, String ns)\r\n   at System.Runtime.Serialization.NetDataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName)\r\n   at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)\r\n   at System.Runtime.Serialization.NetDataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)\r\n   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameter(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)\r\n   at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply(Message message, Object[] parameters)\r\n   at System.ServiceModel.Dispatcher.ProxyOperationRuntime.AfterReply(ProxyRpc&amp; rpc)\r\n   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc&amp; rpc)\r\n   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)\r\n   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)\r\n   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)\r\n   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)\r\n\r\nException rethrown at [0]: \r\n   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)\r\n   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&amp; msgData, Int32 type)\r\n   at ServiceInterface.ICustomerService.GetCustomersWithTheirOrders()\r\n   at ServiceClient.Program.Main(String[] args) in C:\\Projects\\NHibernate\\WCF\\NhibernateAndWcf\\ServiceClient\\Program.cs:line 16\r\n   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ThreadHelper.ThreadStart()&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andres</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-9455</link>
		<dc:creator>Andres</dc:creator>
		<pubDate>Fri, 06 Mar 2009 14:32:51 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-9455</guid>
		<description>Hello

I dowloaded the sample and compiled it.

The domain and nHibernate sections work, but when running the WCF client ( Web or Console ) I get the following Exception

{&quot;Object of type &#039;Iesi.Collections.Generic.HashedSet`1[Northwind.Domain.Entities.Employee]&#039; cannot be converted to type &#039;Iesi.Collections.Generic.ISet`1[Northwind.Domain.Entities.Order]&#039;.&quot;}


Like it is trying to assign an employee object to an Order.

what can be going wrong ?</description>
		<content:encoded><![CDATA[<p>Hello</p>
<p>I dowloaded the sample and compiled it.</p>
<p>The domain and nHibernate sections work, but when running the WCF client ( Web or Console ) I get the following Exception</p>
<p>{&#8220;Object of type &#8216;Iesi.Collections.Generic.HashedSet`1[Northwind.Domain.Entities.Employee]&#8216; cannot be converted to type &#8216;Iesi.Collections.Generic.ISet`1[Northwind.Domain.Entities.Order]&#8216;.&#8221;}</p>
<p>Like it is trying to assign an employee object to an Order.</p>
<p>what can be going wrong ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: N</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-328</link>
		<dc:creator>N</dc:creator>
		<pubDate>Wed, 04 Jun 2008 15:17:05 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-328</guid>
		<description>I agree.. this code is triggered.. but I just don&#039;t know how to workaround it and also how to workaround the problem with the session (as the nHibernate will alway require valid session..) ...

Thanks anyway :)</description>
		<content:encoded><![CDATA[<p>I agree.. this code is triggered.. but I just don&#8217;t know how to workaround it and also how to workaround the problem with the session (as the nHibernate will alway require valid session..) &#8230;</p>
<p>Thanks anyway <img src='http://davybrion.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-326</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Wed, 04 Jun 2008 13:44:33 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-326</guid>
		<description>no idea about the IDataContractSurrogate... or IExtensibleDataObject for that matter

like i said, the only thing i can think of is code in your objects that&#039;s triggered during the deserialization which accesses the proxies. If that&#039;s not it, i can&#039;t help you i guess...</description>
		<content:encoded><![CDATA[<p>no idea about the IDataContractSurrogate&#8230; or IExtensibleDataObject for that matter</p>
<p>like i said, the only thing i can think of is code in your objects that&#8217;s triggered during the deserialization which accesses the proxies. If that&#8217;s not it, i can&#8217;t help you i guess&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: N</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-325</link>
		<dc:creator>N</dc:creator>
		<pubDate>Wed, 04 Jun 2008 13:26:16 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-325</guid>
		<description>In my previous post - ignore the first line - I meant to say that I am not touching the proxies...</description>
		<content:encoded><![CDATA[<p>In my previous post &#8211; ignore the first line &#8211; I meant to say that I am not touching the proxies&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: N</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-324</link>
		<dc:creator>N</dc:creator>
		<pubDate>Wed, 04 Jun 2008 13:19:11 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-324</guid>
		<description>I don&#039;t touch the proxies...they are accessed during serializtion - it doesn&#039;t get to the deseralization.

When I use the sample from MSDN with IExtensibleDataObject i cannot serialize and get an error that the nHibernate proxies do not implement IExtensibleDataObject.

When I use NetDataContractSerializer as is without adding anything (except [Serializable]) then it is serializes but I get the session error when deserialize.

the only thing that worked was DataContractSerializer but then Ilist was deserialized as arrays.

So I am quite lost. I don&#039;t know what to do to get it to work....I am actually thinking of using Linq cos I cannot make the nHibernate to work along with serialization...

Any ideas? The IDataContractSurrogate made DataContractSerializer work... Is there anything simlilar for NetDataContractSerializer?</description>
		<content:encoded><![CDATA[<p>I don&#8217;t touch the proxies&#8230;they are accessed during serializtion &#8211; it doesn&#8217;t get to the deseralization.</p>
<p>When I use the sample from MSDN with IExtensibleDataObject i cannot serialize and get an error that the nHibernate proxies do not implement IExtensibleDataObject.</p>
<p>When I use NetDataContractSerializer as is without adding anything (except [Serializable]) then it is serializes but I get the session error when deserialize.</p>
<p>the only thing that worked was DataContractSerializer but then Ilist was deserialized as arrays.</p>
<p>So I am quite lost. I don&#8217;t know what to do to get it to work&#8230;.I am actually thinking of using Linq cos I cannot make the nHibernate to work along with serialization&#8230;</p>
<p>Any ideas? The IDataContractSurrogate made DataContractSerializer work&#8230; Is there anything simlilar for NetDataContractSerializer?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-323</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Wed, 04 Jun 2008 12:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-323</guid>
		<description>well, if you try to access a proxied object or proxied collection outside of the scope of the session, then it&#039;s normal to get that exception. When you deserialize the object, it&#039;s a different instance than the original one so it&#039;s not connected to the session. 

Are you accessing any proxied objects or proxied collections within your object in code that could be touched during deserialization? Depending on how the NetDataContractSerializer sets the data (through setters for instance), it could trigger code that would access contained proxies which could cause that exception.</description>
		<content:encoded><![CDATA[<p>well, if you try to access a proxied object or proxied collection outside of the scope of the session, then it&#8217;s normal to get that exception. When you deserialize the object, it&#8217;s a different instance than the original one so it&#8217;s not connected to the session. </p>
<p>Are you accessing any proxied objects or proxied collections within your object in code that could be touched during deserialization? Depending on how the NetDataContractSerializer sets the data (through setters for instance), it could trigger code that would access contained proxies which could cause that exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: N</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-322</link>
		<dc:creator>N</dc:creator>
		<pubDate>Wed, 04 Jun 2008 12:06:24 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-322</guid>
		<description>Hi,

Yes.. I am only trying to serialize and deserialize objects but nHibernate keeps messing things.

Now i only have [Serializable] attributes on the classes (no DataContract, DataMember, UseNetDataContractSerializer) and I am still getting the following error when I deserialize:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt;  NHibernate.LazyInitializationException: Could not initialize proxy - no Session..

Also i am not that sure that the object is serialized correctly as when I look at the xml it does not contain a value of a string property the object instance had.

BTW - when I tried to follow the example from msdn using IExtensibleDataObject I got an error that the nHibernate proxies do not implement IExtensibleDataObject.

Do you have any idea how I can simply serialize/deserialize without nHibernate messing everything (and with IList deserialized into Ilist and not arrays).

Many thanks!!

N</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Yes.. I am only trying to serialize and deserialize objects but nHibernate keeps messing things.</p>
<p>Now i only have [Serializable] attributes on the classes (no DataContract, DataMember, UseNetDataContractSerializer) and I am still getting the following error when I deserialize:</p>
<p>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. &#8212;&gt;  NHibernate.LazyInitializationException: Could not initialize proxy &#8211; no Session..</p>
<p>Also i am not that sure that the object is serialized correctly as when I look at the xml it does not contain a value of a string property the object instance had.</p>
<p>BTW &#8211; when I tried to follow the example from msdn using IExtensibleDataObject I got an error that the nHibernate proxies do not implement IExtensibleDataObject.</p>
<p>Do you have any idea how I can simply serialize/deserialize without nHibernate messing everything (and with IList deserialized into Ilist and not arrays).</p>
<p>Many thanks!!</p>
<p>N</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-321</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Wed, 04 Jun 2008 11:46:54 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-321</guid>
		<description>i&#039;m not sure i follow what you&#039;re trying to do but i think you just need to serialize/deserialize your nhibernate objects, without going through WCF services, right?

The [UseNetDataContractSerializer] is a custom attribute which modifies the behavior of a WCF OperationDescription. If you&#039;re not using WCF, simply putting this attribute on your getters isn&#039;t going to make a difference. Unless you modified the code of the attribute to do something completely different.

If you want to use the NetDataContractSerializer directly to serialize/deserialize your classes, you don&#039;t need to use any attributes on the members of your classes. Just tag the classes themselves with [Serializable] and use the NetDataContractSerializer like you would normally use the XmlSerializer.

You can find more information on the NetDataContractSerializer here:
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.netdatacontractserializer.aspx</description>
		<content:encoded><![CDATA[<p>i&#8217;m not sure i follow what you&#8217;re trying to do but i think you just need to serialize/deserialize your nhibernate objects, without going through WCF services, right?</p>
<p>The [UseNetDataContractSerializer] is a custom attribute which modifies the behavior of a WCF OperationDescription. If you&#8217;re not using WCF, simply putting this attribute on your getters isn&#8217;t going to make a difference. Unless you modified the code of the attribute to do something completely different.</p>
<p>If you want to use the NetDataContractSerializer directly to serialize/deserialize your classes, you don&#8217;t need to use any attributes on the members of your classes. Just tag the classes themselves with [Serializable] and use the NetDataContractSerializer like you would normally use the XmlSerializer.</p>
<p>You can find more information on the NetDataContractSerializer here:<br />
<a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.netdatacontractserializer.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.runtime.serialization.netdatacontractserializer.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: N</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-319</link>
		<dc:creator>N</dc:creator>
		<pubDate>Wed, 04 Jun 2008 11:27:57 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-319</guid>
		<description>Hi there,

I need to serialize / deserialize object to cml and since I am using nHibernate I have to use NetDataContractSerializer/DataContractSerializer.

I used the above code and put [UseNetDataContractSerializer] on the getters of the IList (which so far failed to serialize or deserialized as array when using UseNetDataContractSerializer. The serialize works OK now but when I deserialize I get the following exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; NHibernate.LazyInitializationException: Could not initialize proxy - no Session..

Any ideas? Not Really sure what to do.

Thanks
N</description>
		<content:encoded><![CDATA[<p>Hi there,</p>
<p>I need to serialize / deserialize object to cml and since I am using nHibernate I have to use NetDataContractSerializer/DataContractSerializer.</p>
<p>I used the above code and put [UseNetDataContractSerializer] on the getters of the IList (which so far failed to serialize or deserialized as array when using UseNetDataContractSerializer. The serialize works OK now but when I deserialize I get the following exception:</p>
<p>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. &#8212;&gt; NHibernate.LazyInitializationException: Could not initialize proxy &#8211; no Session..</p>
<p>Any ideas? Not Really sure what to do.</p>
<p>Thanks<br />
N</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Davy Brion</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-252</link>
		<dc:creator>Davy Brion</dc:creator>
		<pubDate>Sat, 24 May 2008 11:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-252</guid>
		<description>http://msdn.microsoft.com/en-us/library/system.runtime.serialization.netdatacontractserializer.aspx

the compact framework isn&#039;t listed among the supported .NET frameworks</description>
		<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.netdatacontractserializer.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.runtime.serialization.netdatacontractserializer.aspx</a></p>
<p>the compact framework isn&#8217;t listed among the supported .NET frameworks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: giammin</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-251</link>
		<dc:creator>giammin</dc:creator>
		<pubDate>Sat, 24 May 2008 10:45:35 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-251</guid>
		<description>Is NetDataContractSerializer compatible with Compact Framework?</description>
		<content:encoded><![CDATA[<p>Is NetDataContractSerializer compatible with Compact Framework?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2008-04-08 &#171; dstelow notes&#8230;</title>
		<link>http://davybrion.com/blog/2008/01/sending-nhibernate-entities-over-the-wcf-wire/comment-page-1/#comment-112</link>
		<dc:creator>links for 2008-04-08 &#171; dstelow notes&#8230;</dc:creator>
		<pubDate>Wed, 09 Apr 2008 00:16:06 +0000</pubDate>
		<guid isPermaLink="false">http://ralinx.wordpress.com/2008/01/03/sending-nhibernate-entities-over-the-wcf-wire/#comment-112</guid>
		<description>[...] Sending NHibernate entities over the WCF wire « Davy Brion’s Blog &#8230;By default, WCF services use the DataContractSerializer to serialize/deserialize types. But when you’re using NHibernate, you’re most likely using some of the persistent collection types and proxies. Some people just want to use the same types serv (tags: dev dotnet dataaccess nhibernate wcf ormappers) [...]</description>
		<content:encoded><![CDATA[<p>[...] Sending NHibernate entities over the WCF wire « Davy Brion’s Blog &#8230;By default, WCF services use the DataContractSerializer to serialize/deserialize types. But when you’re using NHibernate, you’re most likely using some of the persistent collection types and proxies. Some people just want to use the same types serv (tags: dev dotnet dataaccess nhibernate wcf ormappers) [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
