1

我正在尝试将工作的 S#arp Architecture MVC 应用程序从具有网络服务身份的应用程序池切换到具有域用户身份的应用程序池。我在 Web 服务器中的用户上运行 aspnet_regiis 并授予用户访问数据库的权限(甚至尝试将其设置为数据库中的系统管理员)。但是,它似乎无法获得 NHibernate 会话。

Exception information: 
Exception type: NullReferenceException 
Exception message: Object reference not set to an instance of an object. 

Request information: 
Request URL: http://<redacted> 
Request path: /<redacted> 
User host address: 10.10.10.10
User: <webuser>
Is authenticated: True 
Authentication Type: Forms 
Thread account name: <MYDOMAIN\MYUSER> 

Thread information: 
Thread ID: 1 
Thread account name: <MYDOMAIN\MYUSER> 
Is impersonating: False 
Stack trace:    at SharpArch.Data.NHibernate.NHibernateSession.get_Current() in C:\MyStuff\Dev\Projects\SharpArchitecture\src\SharpArch\SharpArch.Data\NHibernate\NHibernateSession.cs:line 88
at UserAccount.Persistence.UserRepository.GetByPropertiesPartialMatching(IDictionary`2 exactMatchPropertyValuePairs, IDictionary`2 partialMatchPropertyValuePairs, MatchMode matchMode) in c:\Persistence\UserRepository.cs:line 66
...

在 SharpArch NHibernateSession.cs 中给出 Null 引用异常的实际行是:

ISession session = Storage.Session;
4

2 回答 2

1

Clear your temp files on the server. I know it sounds crazy, but S# does file caching on the config.

I've done this several times, but have never seen the problem you are reporting. Do ANY of your calls to repositories (any of them) succeed or all but this one?

Here is what is sticking out to me. Your application spins up. If it had a connection issue, it would not be able to spin the application up. That is leading me to believe you might have another issue.

于 2012-10-31T19:37:54.697 回答
0

这个问题的根本原因是在此之前实际上存在另一个异常,即 NHibernate“无法编译映射文档”。原因是 .NET XMLSerializer 需要对 c:\windows\temp 进行写访问。我右键单击此文件夹并添加了具有修改权限的应用程序池身份(域用户)。那时就修好了。这在NHibernate MappingException 中都有解释:无法编译映射文档

(所以它确实与临时文件有关,Alec。)

于 2012-11-10T00:26:35.163 回答