FluentNHibernate 在 Windows 服务中崩溃,但在网站中没有崩溃

发布于 2024-09-16 13:11:04 字数 768 浏览 7 评论 0原文

我有一个类库来完成我所有的 NHibernate 工作。它还使用 Fluent NHibernate 处理所有映射 - 无需部署映射文件。

该类库由许多应用程序使用,包括在我的计算机上运行的 Windows 服务。虽然它在我的所有 Web 应用程序中工作正常,但 Windows 服务在尝试使用 NHibernate 时会收到此消息:

创建 SessionFactory 时使用了无效或不完整的配置。检查 PotentialReasons 集合和 InnerException 了解更多详细信息。 在 FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() 在 C:\Kctc\Trunk\Kctc.NHibernate\KctcSessionFactory.cs 中的 Kctc.NHibernate.KctcSessionFactory.get_SessionFactory() 处:第 28 行 ...更多堆栈跟踪...

我已经检查了 InnerException,但似乎没有。我不知道 PotentialReasons 集合是什么,Google 似乎也没有提供。

这是我的开发计算机,因此当我处理 Web 应用程序时,它们在本地运行(即使用 Visual Studio 中的 Web 服务器)。 Windows 服务和我的开发 Web 应用程序在同一台计算机上运行这一事实表明,这与信任设置或您拥有的其他内容无关。

谁能建议我应该尝试什么?这是我感到非常困惑的问题之一,我什至不知道如何获得有关该问题的更多信息。

I've got a class library doing all my NHibernate stuff. It also handles all the mapping using Fluent NHibernate - no mapping files to deploy.

This class library is consumed by a number of apps, including a Windows Service running on my computer. Although it works fine in all my web apps, the Windows Service gets this when it tries to use NHibernate:

An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
at Kctc.NHibernate.KctcSessionFactory.get_SessionFactory() in C:\Kctc\Trunk\Kctc.NHibernate\KctcSessionFactory.cs:line 28
...more stack trace...

I have checked for an InnerException and there doesn't appear to be one. I have no idea what the PotentialReasons collection is, and Google doesn't seem to be forthcoming either.

This is my dev machine, so when I'm working on my web apps they run locally (i.e. using the web server in Visual Studio). The fact that the Windows Service and my dev web apps are running on this same machine suggest it's not to do with trust settings or what have you.

Can anyone suggest what I should try? This is one of those ones where I'm so stumped I can't even think of how to get more information about the problem.

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

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

发布评论

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

评论(3

深海少女心 2024-09-23 13:11:04

只是一个疯狂的猜测。 NHibernate 从执行目录中获取 hibernate.cfg.xml 文件。您是否配置了服务的执行目录以使其可以找到该文件?

Just a wild guess. NHibernate picks up the hibernate.cfg.xml file from the execution directory. Did you configure the execution directory of the service that it can find this file?

甜是你 2024-09-23 13:11:04

我已经知道问题出在哪里了。该服务未使用所需的 NHibernate.ByteCode.LinFu.dll 进行部署。

我似乎一直存在 Visual Studio 编译器在构建过程中不总是将间接依赖项(即应用程序所需的类库所需的 dll)复制到输出文件夹中的问题。我真的应该早点想到这一点。

谢谢你们为我绞尽脑汁。

I've found out what the problem is. The Service did not deploy with the required NHibernate.ByteCode.LinFu.dll.

I appear to have an ongoing problem with the Visual Studio compiler not always copying indirect dependencies (i.e. dlls required by class libraries required by the app) into the output folder during the build. I should have thought of this sooner really.

Thanks for racking your brains on my behalf guys.

じее 2024-09-23 13:11:04

我敢打赌 app.config 中缺少连接字符串的名称。对我来说,该消息几乎完全是缺少连接字符串。

您的目标是同一个数据库还是数据库之间存在某种架构不匹配?

是否是服务上的身份验证问题,例如您使用无法使用的 Windows 身份验证(或不起作用的 sql 身份验证)?

没有代码的时候很难说,只有例外!

编辑您是否曾经使用过 HttpContext、HostingEnvironment 或其他特定于“网络”的内容?

I bet the name of the connection string is missing from the app.config. For me that message is almost exclusively a missing connection string.

Are you targeting the same database or could it be some sort of schema mismatch between databases?

Could it be authentication issues on the service like you use windows authentication where it can't be used (or the sql authentication that doesn't work)?

It's hard to tell when there is no code, just an exception!

EDIT Are you ever using HttpContext, HostingEnvironment or anything else specific to "web"?

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