Question

I'm trying to switch a working S#arp Architecture MVC application from an app pool with the Network Service identity to an app pool with a domain user identity. I ran aspnet_regiis on the user in the web server and gave the user permissions to access the database (even tried making it a sysadmin in the database). However, it seems like it can't get the NHibernate session.

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

The actual line giving the Null reference exception within SharpArch NHibernateSession.cs is:

ISession session = Storage.Session;
Was it helpful?

Solution 2

The root cause of this issue was that there was actually another exception before this one where NHibernate "couldn't compile the mapping document". The reason was that the .NET XMLSerializer needs write access to c:\windows\temp. I right-clicked this folder and added my application pool identity (a domain user) with Modify permission. It was fixed then. This is all explained in NHibernate MappingException: Could not compile the mapping document

(So it was indeed related to temp files, Alec.)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top