NHibernate 2.1 应用程序正在寻找 3.0 参考吗?

发布于 2024-09-13 13:20:43 字数 2423 浏览 2 评论 0原文

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

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>

I have an odd problem. I have a number of C# apps that utilize Nhibernate 2.1.
Within the last 2 days I've begun receiving the following error:

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)

I cannot for the life of me locate the cause of this problem, I've not updated my reference assemblies and the correct v2.1 .dll's are where they should be. I've cleaned the solution entirely and recompiled and I'm convinced it is not a mapping issue as known-working objects now fail to retrieve. Regardless below are my object and mapping.

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

聆听风音 2024-09-20 13:20:43

更新:这是幻影 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>

删除它可以解决问题。

UPDATE: This was the cause of a phantom app.config entry. I am unsure how it was added but this line was present:

<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>

Removing this fixed the problem.

阿楠 2024-09-20 13:20:43

我没有进行任何与 Nhibernate 相关的更改,我无法推断出导致此错误的原因;它不再是一个问题,它一抬起丑陋的头就消失了!

There had been no Nhibernate-related changes on my behalf, I was unable to deduce what caused this error; it is no longer an issue, it disappeared as promptly as it reared it's ugly head!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文