我有一個sql類中的表,其中有一列是一個ID,另一個是fImage。 fImage列的數據類型是Image。我使用nhibernate加載所有圖像,並希望將其綁定到圖片框控件中。但是,當使用nhibernate讀取數據時,我們正在發生異常nhibernate無法反序列化可序列化的屬性。Nhibernate無法反序列化一個可序列化的屬性
我經歷了一些鏈接在stackoverflow和谷歌,但似乎沒有爲我工作。
這裏我給出了示例hbm文件和類文件。
namespace BlackOpsP2.Core.Domain.ARModule
{
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
/// <summary>
/// Documentation for the tARReportLogo.
/// </summary>
public partial class tARReportLogo : DomainObject<System.Guid>
{
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="tARReportLogo"/> class.
/// </summary>
public tARReportLogo()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="tARReportLogo"/> class.
/// </summary>
/// <param name="fReportLogoID">The Payment Type ID.</param>
public tARReportLogo(System.Guid fReportLogoID)
{
this.ID = fReportLogoID;
}
#endregion
#region Properties
/// <summary>
/// Gets or sets ReportLogoID.
/// </summary>
public virtual System.Guid fReportLogoID { get; set; }
/// <summary>
/// Gets or sets Image ID.
/// </summary>
public virtual System.Guid fImageID { get; set; }
/// <summary>
/// Gets or sets Image Name.
/// </summary>
public virtual string fImageName { get; set; }
/// <summary>
/// Gets or sets Image Value.
/// </summary>
public virtual Image fImageValue { get; set; }
#endregion
#region Methods
/// <summary>
/// Joins a first name and a last name together into a single string.
/// </summary>
/// <returns>The hash code.</returns>
public override int GetHashCode()
{
return ID.GetHashCode();
}
#endregion
}
}
這裏是HBM文件
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping assembly="BlackOpsP2.Core" namespace="BlackOpsP2.Core.Domain.ARModule" xmlns="urn:nhibernate-mapping-2.2">
<class name="tARReportLogo" table="tARReportLogo" lazy="true" >
<id name="fReportLogoID">
<generator class="guid" />
</id>
<property name="fImageID">
</property>
<property name="fImageName" >
</property>
<property name="fImageValue" type="Serializable" length="2147483647">
</property>
</class>
</hibernate-mapping>
我使用NHibernate 3.3版本。
感謝,
任何內部異常? –
{「輸入流不是有效的二進制格式,起始內容(字節)爲:42-4D-DE-19-00-00-00-00-00-00-36-04-00-00- 28-00-00 ...「} – Awadhendra