These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Could not load file or assembly 'NHibernate...'
PostPosted: Sat Jul 21, 2007 8:21 pm 
Newbie

Joined: Mon Aug 15, 2005 12:34 pm
Posts: 2
Hi,

I have a web app where I use NHibernate. I use the "session per request" pattern. There is an HttpModule, NHibernateSessionModule, that begins a transaction when a new request is received:


Code:
NHibernateSessionManager.Instance.BeginTransaction();



and closes the transaction when the request ends:


Code:
       try
                {
                    NHibernateSessionManager.Instance.CommitTransaction();
                }
                finally
                {
                    NHibernateSessionManager.Instance.CloseSession();
                }


Initially all goes well, but after some time, with some yet unidentified trigger, I get the error that follows. Sometimes I get the same error on the log4net assembly, other times I have seen the error occur on the Castle assembly. Changing the security so that the "IIS_WPG" user can access the file seems to fix the problem. "IIS_WPG" seems to already have access to this file sometimes at least and just flipping it back and forth fixes the problem.I have trouble getting access to the box so I am cautionary saying IIS_WPG always had access to all the NHibernate related assemblies initially.

To clarify, the web app, including NHibernate service, works for some period of time - I can hit pages that use it and see that the assemblies are used successfully, and then suddenly I get this "Access Denied" error. Any ideas? Should the probing be going to the NHibnerate.dll in the \bin directory, or should the worker process' probing be finding a copy in the "Temporary ASP.NET Files" folder? Or the copy in the \bin folder? Of course the copy in the \bin folder seems to be locked by the worker process itself, but that seems pretty standard...

Thanks,

JP

Error:

--------------------------------------------------------------------

Could not load file or assembly 'NHibernate, Version=1.0.3.0, Culture=neutral, PublicKeyToken=3a53e011584a29df' or one of its dependencies. Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'NHibernate, Version=1.0.3.0, Culture=neutral, PublicKeyToken=3a53e011584a29df' or one of its dependencies. Access is denied.

Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'NHibernate, Version=1.0.3.0, Culture=neutral, PublicKeyToken=3a53e011584a29df' could not be loaded.

Assembly manager loaded from: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = MyDomain\MyUser
LOG: DisplayName = NHibernate, Version=1.0.3.0, Culture=neutral, PublicKeyToken=3a53e011584a29df
(Fully-specified)
LOG: Appbase = file:///C:/Inetpub/wwwroot/MyApp/
LOG: Initial PrivatePath = C:\Inetpub\wwwroot\MyApp\bin
Calling assembly : MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Inetpub\wwwroot\MyApp\web.config
LOG: Using host configuration file: \\?\c:\windows\microsoft.net\framework\v2.0.50727\aspnet.config
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: NHibernate, Version=1.0.3.0, Culture=neutral, PublicKeyToken=3a53e011584a29df
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/MyApp/32ca0e24/8f29262d/NHibernate.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/MyApp/32ca0e24/8f29262d/NHibernate/NHibernate.DLL.
LOG: Attempting download of new URL file:///C:/Inetpub/wwwroot/MyApp/bin/NHibernate.DLL.
ERR: Failed to complete setup of assembly (hr = 0x80070005). Probing terminated.



Hibernate version:
1.0.3.0

Code between sessionFactory.openSession() and session.close():


Full stack trace of any exception that occurs:

[FileLoadException: Could not load file or assembly 'NHibernate, Version=1.0.3.0, Culture=neutral, PublicKeyToken=3a53e011584a29df' or one of its dependencies. Access is denied.]
MyAssembly.NHibernateSessionManager.InitSessionFactory() +0
MyAssembly.NHibernateSessionManager..ctor() +33
MyAssembly.Nested..cctor() +34

[TypeInitializationException: The type initializer for 'Nested' threw an exception.]
MyAssembly.NHibernateSessionManager.get_Instance() +32
MyAssembly.NHibernateSessionModule.CommitAndCloseSession(Object sender, EventArgs e) +54
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

Name and version of the database you are using:
SQL Server


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.