- Posted by dan on March 21, 2011
Ok I'm going to keep this short. I had this issue ages ago, and it's just resurfaced and taken another hour of my life to solve.
For me it came, while my Console application using NHibernate works perfectly when I move it into IIS7 on Windows 7, suddenly it won't work.
The inner exception is this:
{"Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}
With an ultimate stack trace being as shown below.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.AppDomainSetup.VerifyDir(String dir, Boolean normalize)
at System.AppDomain.get_BaseDirectory()
at NHibernate.LoggerProvider.GetNhibernateLoggerClass()
at NHibernate.LoggerProvider..cctor()
After some googling, it seems something to do with Medium trust. Only this is on my local machine and I have Full Trust weird. The problem ends up being due to CodeAccessSecurity for downloaded assemblies. Now I suppose it's a nice security feature but an annoying one.
To solve it, simply goto properties of the dll then click unblock I did this for all NHibernate and Lucene.net assemblies just to be sure.

Hope that helps someone, or me several months from now.