WCF+NHibernate 序列化

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   ar   使用   sp   檔案   

最近使用WCF+NHibernate 時候 發生序列化問題 困擾了好久  

用戶端有的方法會報  “服務端點未使用HTTP 綁定造成。。。。”  這個錯誤

發生的原因大體上是因為:資料內容過大或者是WCF傳回值無法序列化造成的

資料量過大:在用戶端和服務端設定檔 添加上

<dataContractSerializer maxItemsInObjectGraph="65536000" />


無法序列化這點困擾了我好久,大體感覺是因為資料契約的導致的,通過 Trace Viewer 找到了,發生這些錯誤的都是因為我有級聯屬性的欄位。

使用 knowntype 每一個類標記太麻煩了  寫了一個簡單類

WCF:

[DataContract(IsReference = true)][KnownType("GetKnownType")]class Entity{      private static Type[] GetKnownType()        {            //將自訂對象的程式集下的所有類型標記為KnownType。              return Assembly.Load("WCF.Entity").GetTypes();        }  }

 

NHibernate:
多對一端  lazy = fasle

一對多端  <bag>

實體類:[DataContract(IsReference = true)]

[DataContract(IsReference = true)]

 

WCF+NHibernate 序列化

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.