Hi!
I'm using Nhibernate for Reporting Service datasource, It works fine
when objects are not laizy loaded.
But when objects are laizy loaded (previously not prefetched), NHibernate tries to open another connection for prefetching the data.
This should be ok, if Nhibernate want's the new connection then fine, but
it produces an security exeption:
Code:
NHibernate.Util.ADOExceptionReporter [(null)] (null) - Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
NHibernate.Util.ADOExceptionReporter [(null)] (null) - NHibernate.ADOException: cannot open connection ---> System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.PermissionSet.Demand()
at System.Data.Common.DbConnectionOptions.DemandPermission()
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at NHibernate.Connection.DriverConnectionProvider.GetConnection()
at NHibernate.Impl.SessionFactoryImpl.OpenConnection()
The action that failed was:
Demand
The type of the first permission that failed was:
System.Data.SqlClient.SqlClientPermission
The Zone of the assembly that failed was:
MyComputer
--- End of inner exception stack trace ---
So it raises a question, why Nhibernate tries to open a new connection. And how could I resolve this issue?