NHibernate 2.1 App寻找3.0参考?

时间:2010-08-10 18:44:08

标签: nhibernate nhibernate-mapping

我有一个奇怪的问题。我有许多使用Nhibernate 2.1的C#应用​​程序。 在过去的两天内,我开始收到以下错误:

Could not load file or assembly 'NHibernate, Version=3.0.0.1001, Culture=neutral,
PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's 
manifest definition does not match the assembly reference. (Exception from HRESULT: 
0x80131040)

我不能为我的生活找到这个问题的原因,我没有更新我的参考组件和正确的v2.1 .dll是他们应该在的地方。我完全清理了解决方案并重新编译,我确信它不是映射问题,因为已知的工作对象现在无法检索。无论下面是我的对象和映射。

using System;
using System.IO;
using System.Collections.Generic;

namespace Epn.Assembly.Domain
{
   public class Email
   {
        public int EmailId { get; set; }

        public string Sender { get; set; }
        public string Recipient { get; set; }
        public string CC { get; set; }
        public string BCC { get; set; }
        public string Subject { get; set; }
        public string Body { get; set; }
        public string EmailType { get; set; }
        public Nullable<DateTime> SentDateTime { get; set; }
        public string ErrorMessage { get; set; }
        public DateTime QueueDateTime { get; set; }
        public DateTime LastActivityDateTime { get; set; }
        public bool HoldForReview { get; set; }

    }
}



<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" schema="SystemStatusDb.dbo" auto-import="true" assembly="EpnDomain" namespace="Epn.Assembly.Domain">
  <class name="Epn.Assembly.Domain.Email, EpnDomain" lazy="false" table="EpnEmails">

    <id name="EmailId" column="EmailId">
      <generator class="native" />
    </id>

    <property name="Sender" column="Sender"/>
    <property name="Recipient" column="Recipient" />
    <property name="CC" column="CC" />
    <property name="BCC" column="BCC" />
    <property name="Subject" column="Subject" />
    <property name="Body" column="Body" />
    <property name="EmailType" column="EmailType" />
    <property name="SentDateTime" column="SentDateTime" />
    <property name="ErrorMessage" column="ErrorMessage" />
    <property name="QueueDateTime" column="QueueDateTime" />
    <property name="LastActivityDateTime" column="LastActivityDateTime" />
    <property name="HoldForReview" column="HoldForReview" />

  </class>
</hibernate-mapping>

2 个答案:

答案 0 :(得分:1)

更新:这是幻像app.config条目的原因。我不确定它是如何添加的,但这条线存在:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="NHibernate" publicKeyToken="AA95F207798DFDB4" culture="neutral"/>
            <bindingRedirect oldVersion="0.0.0.0-3.0.0.1001" newVersion="3.0.0.1001"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

删除此功能解决了问题。

答案 1 :(得分:0)

我的代表没有与Nhibernate相关的更改,我无法推断导致此错误的原因;它已经不再是一个问题了,它很快就消失了,因为它的头脑很难看!