properties out-side <session-factory> (as reflection-optimizer) can work
only if you put that minimal configuration inside web.config.
http://fabiomaulo.blogspot.com/2009/06/nhibernate-configuration.html

2010/1/23 Sam Kimmel <[email protected]>

> Fabio, thanks for pointing me in the right direction.  Between your
> help with telling me about needing to recompile the
> NHibernate.ByteCode.Castle library with Castle Dynamic Proxy 2.2, and
> the help from some users over in the Castle user group I was able to
> get everything up and running in Medium Trust.  We'll see if I hit any
> limitations down the road, but for the time being I'm able to create
> and query records which is a 100% further than where I was last week.
>
> For those who are struggling getting this to work in Medium Trust, I
> jotted down the steps I took to get it to work over in the Castle
> Group:
> http://groups.google.com/group/castle-project-users/browse_thread/thread/2451ef352523865f?hl=en
>
> One last question...
>
> I was unable to get the <reflection-optimizer use="false"/> attribute
> to work in the hibernate.cfg.xml file.  I worked around it by doing
> this intead:
>
> NHibernate.Cfg.Environment.UseReflectionOptimizer = false;
> config = new Configuration().Configure();
>
> Should the XML configuration be working?
>
> On Jan 22, 1:12 am, Sam Kimmel <[email protected]> wrote:
> > I downloaded the Castle Dynamic Proxy trunk and noticed that there was
> > not an AssemblyInfo file so I added one and slipped in the
> > AllowPartiallyTrustedCallers attribute.  I built it succesfully, but
> > when I try to use it I get the error below.  I noticed some .build
> > files scattered throughout the project so I'm guessing that they do
> > not use the Visual Studio build, but something like Nant.  That would
> > also explain some other things like my assembly being named
> > Castle.DynamicProxy instead of Castle.DynamicProxy2 and the inability
> > to do a Release build.
> >
> > While I'm learning quite a bit about the different programs everyone
> > uses for open souce (SVN clients, NANT, SourceForge), I'm getting
> > tired of staying up every night until 2 a.m. trying to figure out how
> > to get a simple, 1 POCO example project running in Medium Trust.  I've
> > invested so much time into this that I don't want to turn back now,
> > but I'm running out of options. I can't afford to spend too much more
> > time trying to make this work.
> >
> > Probably the thing that is most dissappointing is that there are
> > several blogs and resources on the web explaining how to get
> > NHibernate working in Medium Trust, but 95% of them are out of date.
> > From what I read, it sounded like Castle Dynamic Proxy 2.2 should have
> > fixed the Medium Trust issues, but as you can see from the previous
> > error I posted, there is still something weird going on.
> >
> > Anyway, it appears to be a Castle issue and not an NHibernate one.
> > I'll try learning a little about NANT tomorrow and see if I can get a
> > clean build with the APTCA attribute using that.  If that doesn't
> > work, how stable was the NH 2.0.1 release (the one used in Proxy
> > Generators Beta 621)?  How much functionality/optimization/bug fixes
> > would I be missing out on if I used that instead of 2.1.2?
> >
> > =======================================
> >
> > Could not load file or assembly 'Castle.DynamicProxy2' or one of its
> > dependencies. The located assembly's manifest definition does not
> > match the assembly reference. (Exception from HRESULT: 0x80131040)
> > 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 'Castle.DynamicProxy2' or one of its dependencies. The
> > located assembly's manifest definition does not match the assembly
> > reference. (Exception from HRESULT: 0x80131040)
> >
> > 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 'Castle.DynamicProxy2' could not be loaded.
> >
> > WRN: Assembly binding logging is turned OFF.
> > To enable assembly bind failure logging, set the registry value [HKLM
> > \Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
> > Note: There is some performance penalty associated with assembly bind
> > failure logging.
> > To turn this feature off, remove the registry value [HKLM\Software
> > \Microsoft\Fusion!EnableLog].
> >
> > Stack Trace:
> >
> > [FileLoadException: Could not load file or assembly
> > 'Castle.DynamicProxy2' or one of its dependencies. The located
> > assembly's manifest definition does not match the assembly reference.
> > (Exception from HRESULT: 0x80131040)]
> >    System.Reflection.Assembly._nLoad(AssemblyName fileName, String
> > codeBase, Evidence assemblySecurity, Assembly locationHint,
> > StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean
> > forIntrospection) +0
> >    System.Reflection.Assembly.nLoad(AssemblyName fileName, String
> > codeBase, Evidence assemblySecurity, Assembly locationHint,
> > StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean
> > forIntrospection) +43
> >    System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,
> > Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
> > forIntrospection) +127
> >    System.Reflection.Assembly.InternalLoad(String assemblyString,
> > Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
> > forIntrospection) +142
> >    System.Reflection.Assembly.Load(String assemblyString) +28
> >    System.Web.Configuration.CompilationSection.LoadAssemblyHelper
> > (String assemblyName, Boolean starDirective) +46
> >
> > [ConfigurationErrorsException: Could not load file or assembly
> > 'Castle.DynamicProxy2' or one of its dependencies. The located
> > assembly's manifest definition does not match the assembly reference.
> > (Exception from HRESULT: 0x80131040)]
> >    System.Web.Configuration.CompilationSection.LoadAssemblyHelper
> > (String assemblyName, Boolean starDirective) +613
> >
> >
> System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory
> > () +203
> >    System.Web.Configuration.CompilationSection.LoadAssembly
> > (AssemblyInfo ai) +105
> >    System.Web.Compilation.BuildManager.GetReferencedAssemblies
> > (CompilationSection compConfig) +178
> >    System.Web.Compilation.WebDirectoryBatchCompiler..ctor
> > (VirtualDirectory vdir) +163
> >    System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal
> > (VirtualDirectory vdir, Boolean ignoreErrors) +53
> >    System.Web.Compilation.BuildManager.BatchCompileWebDirectory
> > (VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors)
> > +175
> >    System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath
> > virtualPath) +86
> >    System.Web.Compilation.BuildManager.GetVPathBuildResultInternal
> > (VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp,
> > Boolean allowBuildInPrecompile) +261
> >    System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert
> > (HttpContext context, VirtualPath virtualPath, Boolean noBuild,
> > Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
> >    System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory
> > (VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp,
> > Boolean noAssert) +126
> >    System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath
> > (VirtualPath virtualPath, Type requiredBaseType, HttpContext context,
> > Boolean allowCrossApp, Boolean noAssert) +62
> >    System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext
> > context, String requestType, VirtualPath virtualPath, String
> > physicalPath) +33
> >
> >
> System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler
> > (HttpContext context, String requestType, VirtualPath virtualPath,
> > String physicalPath) +40
> >    System.Web.HttpApplication.MapHttpHandler(HttpContext context,
> > String requestType, VirtualPath path, String pathTranslated, Boolean
> > useAppConfig) +160
> >
> >
> System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
> > () +93
> >    System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
> > Boolean& completedSynchronously) +155
> >
> > ============================================
> >
> > On Jan 22, 12:07 am, Sam Kimmel <[email protected]> wrote:
> >
> > > Fabio, I tried what you recommended and I still get the following
> > > error.  I'm going to try to download the source for the Castle Dynamic
> > > Proxy 2.2 and see if I can add the AllowPartiallyTrustedCallers
> > > attribute.  [P.S. - I double checked and all my solutions assemblies
> > > are marked with with the AllowPartiallyTrustedCallers.  Will let you
> > > know what I figure out.
> >
> > > ===============================
> >
> > > Security Exception
> > > Description: The application attempted to perform an operation not
> > > allowed by the security policy.  To grant this application the
> > > required permission please contact your system administrator or change
> > > the application's trust level in the configuration file.
> >
> > > Exception Details: System.Security.SecurityException: That assembly
> > > does not allow partially trusted callers.
> >
> > > 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.
> >
> > > Stack Trace:
> >
> > > [SecurityException: That assembly does not allow partially trusted
> > > callers.]
> > >    Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly,
> > > INamingScope namingScope, String strongAssemblyName, String
> > > strongModulePath, String weakAssemblyName, String weakModulePath) +0
> > >    Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly,
> > > String strongAssemblyName, String strongModulePath, String
> > > weakAssemblyName, String weakModulePath) +75
> > >    Castle.DynamicProxy.ModuleScope..ctor(Boolean savePhysicalAssembly)
> > > +62
> > >    Castle.DynamicProxy.ModuleScope..ctor() +31
> > >    Castle.DynamicProxy.DefaultProxyBuilder..ctor() +44
> > >    Castle.DynamicProxy.ProxyGenerator..ctor() +44
> > >    NHibernate.ByteCode.Castle.ProxyFactory..cctor() +49
> >
> > > ================================
> >
> > > On Jan 21, 2:39 pm, Sam Kimmel <[email protected]> wrote:
> >
> > > > So the error above is a known issue with Castle Dynamic Proxy 2.1?
> > > > I'll try your suggestions when I get home tonight.
> >
> > > > On Jan 21, 2:03 pm, Fabio Maulo <[email protected]> wrote:
> >
> > > > > Now you can :
> > > > > 1) download NH2.1.2GA sources
> > > > > 2) download the new version of Castle's Dynamic Proxy 2.2
> > > > > 3) Copy Castle.Core and Castle.DynamicProxy2 in the lib folder of
> NH
> > > > > 4) compile NHibernate.ByteCode.Castle
> > > > > 5) work as normal ;)
> >
> > > > > 2010/1/21 Sam Kimmel <[email protected]>
> >
> > > > > > I am working on a web project and medium trust is a requirement.
> I
> > > > > > downloaded the NHibernate Proxy Generator contrib (1.0.0 Beta
> 621) and
> > > > > > quickly found out that it was created with NH 2.0.1, which was
> before
> > > > > > the Castle Proxy stuff was split out.
> >
> > > > > > I wanted to work with the latest and greatest so I downloaded the
> > > > > > source for the NHPG and updated all of the assembly references to
> the
> > > > > > latest stable releases for NH and Castle, added in the
> IProxyValidator
> > > > > > stuff, and recompiled without errors.
> >
> > > > > > The problem is that now when I run the proxy generator I get the
> >
> > ...
> >
> > read more ยป
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>


-- 
Fabio Maulo

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to