我修改了NHibernate;如何让 Castle 使用不同键控的 NH 组件?

发布于 2024-10-26 12:42:54 字数 1315 浏览 4 评论 0原文

我对 NHibernate 2.1.2 进行了更改,因此一直在与 .NET 和强大的程序集名称进行斗争。我已经设置了一个 ResolveEventHandler 来加载我已经签名的 NHibernate 版本,我在构建会话工厂之前注册了该版本:

Assembly ModifiedNHibernateAssemblyResolver(object sender, ResolveEventArgs args) {
    var name = new AssemblyName(args.Name);
    switch (name.Name) {
        case "NHibernate":
            return typeof(NHibernate.NHibernateUtil).Assembly;
    }
    return null;
}

我得到对“NHibernate.XmlSerializers,Version = 2.1.2.4000,Culture =neutral, PublicKeyToken=3557c07e7d6e1f91”现在它已签名(而不是一个带有该令牌的令牌,后跟一个带有令牌= null的令牌),但在遇到 Castle 时无法加载:

Could not load type NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle.
System.IO.FileLoadException: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

未签名时,SysCache 加载失败,现在是在这里,我不知道为什么。我没有看到任何有关加载 SysCache 的日志记录引用,因此我认为加载顺序已更改,但我的问题是错误本身。两者之间唯一的区别是公钥令牌,版本相同,我只有一个 NHibernate 程序集,我通过浏览在项目中引用了该程序集(GAC 中没有),但我陷入了困境。

有没有办法使用不同的公钥加载程序集?如果没有,我应该如何对 NHibernate 进行修改,以便我仍然可以使用其他库,其中一些库可能无法在我的密钥下编译?


编辑:为了使这个问题成为一个更通用的问题,因为它可能是一个通用问题:如何加载具有与另一个项目预期不同的公钥令牌的程序集?
如果没有办法的话,这似乎意味着你自己对开源项目进行修改意味着死亡,因为那样你就无法将它与任何东西一起使用。如果您对其进行签名,则任何使用它的内容都会被粘贴到您的代码中。如果你不这样做,任何经过签名的东西都无法调用你的代码......

I made a change to NHibernate 2.1.2, and as such have been doing battle with .NET and strong assembly names. I've set up a ResolveEventHandler to load my version of NHibernate, which I've signed, which I register before building my session factory:

Assembly ModifiedNHibernateAssemblyResolver(object sender, ResolveEventArgs args) {
    var name = new AssemblyName(args.Name);
    switch (name.Name) {
        case "NHibernate":
            return typeof(NHibernate.NHibernateUtil).Assembly;
    }
    return null;
}

I get single-references to "NHibernate.XmlSerializers, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=3557c07e7d6e1f91" now that it's signed (rather than one with that token followed by one with the token = null), but it's failing to load when it encounters Castle:

Could not load type NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle.
System.IO.FileLoadException: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

When un-signed, it was failing on the SysCache load, now it's here, and I have no idea why. I don't see any logging references to loading SysCache, so I think the loading order has changed, but my problem is the error itself. The only differences between the two are the public key tokens, versions are the same, I only have one NHibernate assembly which I reference in the project by browsing (none in GAC), and I'm stuck.

Is there a way to load an assembly with a different public key? If not, how should I go about making modifications to NHibernate so I can still use other libraries, some of which I may not be able to compile under my key?


Edit: to make this a more generic question, as it's likely a generic problem: how can I load an assembly with a different public key token than another project expects?
It seems like this would mean death to making your own modifications to open source projects if there's no way, as then you couldn't use it with anything. If you sign it, anything which uses it is stuck to your code. If you don't, anything which is signed can't call your code...

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

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

发布评论

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

评论(1

Bonjour°[大白 2024-11-02 12:42:54

我通过从头开始构建所有源代码并删除签名来做到这一点。对我来说,这是最简单的课程,但是,可能有更好的选择。

I did it by building all the sources from scratch, removing the signing. For me it was the simplest course, however, there may be a better alternative.

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