NHibernate - 缺少 dll

发布于 2024-09-16 05:57:44 字数 569 浏览 3 评论 0原文

// this._cfg

是一个 NHibernate 配置实例
this._sessionFactory = this._cfg.BuildSessionFactory();

在运行时(而不是在编译时)给我这个异常。

无法加载文件或程序集“NHibernate.ByteCode.Castle”或其依赖项之一。系统找不到指定的文件。":"NHibernate.ByteCode.Castle

到目前为止正常。但问题是,这段代码正在一个类库项目中运行,并且我在该项目中引用了 NHibernate.ByteCode.Castle(以及所有其他 NHibernate dll)。

Wierder:我可以通过另外引用调用我的类库的 Windows WPF 可执行项目中的 NHibernate dll 来修复该异常。但是 Windows WPF 可执行文件不包含直接使用 NHibernate 的代码(证据如下:它可以在没有任何 NHibernate 引用的情况下编译良好)。那么到底是怎么回事呢?显然,在实际使用 NHibernate 东西的项目中引用 NHibernate.ByteCode.Castle 是不够的。有人知道为什么吗?

This call

// this._cfg is an NHibernate Configuration instance
this._sessionFactory = this._cfg.BuildSessionFactory();

Gives me this exception at runtime (NOT at compile time).

Could not load file or assembly 'NHibernate.ByteCode.Castle' or one of its dependencies. The system cannot find the file specified.":"NHibernate.ByteCode.Castle

OK so far. But the thing is, this code is running in a class library project, and I have referenced NHibernate.ByteCode.Castle (along with all the other NHibernate dll's) in that project.

Wierder: I can fix the exception by additionally referencing the NHibernate dll's in the Windows WPF executable project that calls my class library. But the Windows WPF executable contains no code that directly uses NHibernate (as evidenced by: It compiles fine without any NHibernate references). So what's going on? Apparently it's insufficient to reference NHibernate.ByteCode.Castle in the project that actually uses the NHibernate stuff. Anyone know why?

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

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

发布评论

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

评论(2

萝莉病 2024-09-23 05:57:44

我知道这已经很旧了,但是我为解决依赖性问题所做的事情很简单:

在我的 UnitOfWork 中,我添加了一个静态方法:

private static void bringCastleDamnit()
{
   var pf = new NHibernate.ByteCode.Castle.ProxyFactoryFactory();
}

然后,只有到那时,MSBuild 才会发现需要它并将其复制到我的输出目录中我的(asp.net 和控制台)应用程序引用了我的数据项目。

I know this is old, but what I've done to fix the dependency problem is simple:

In my UnitOfWork I added one static method:

private static void bringCastleDamnit()
{
   var pf = new NHibernate.ByteCode.Castle.ProxyFactoryFactory();
}

Then, and only then, would MSBuild see that it was needed and copy it to my output directory for my (asp.net and console) apps that references my Data project.

情话难免假 2024-09-23 05:57:44

我根本不会引用城堡字节码工厂;只需确保使用构建后步骤将其(以及所有其他所需的依赖项)复制到输出目录即可。

I wouldn't reference the castle byte code factory at all; just ensure it (and all other needed dependancies) are copied to the output directory using a post-build step.

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