Morten, I know very well the guy who wrote the chunk of code (unlucky I'm seeing him every day in the mirror ) ;) What I said is that you can use the app/web config to configure only the reflection-optimizer usage and then use an external file for the others stuff (the configuration of the session-factory).
2009/10/8 Morten Maxild <[email protected]> > Hi, > > > > In my experience you have to use app/web config to setup the system > properties (reflection-optimizer and bytecode-provider) when running in > medium trust, because some “NH infrastructure components” > (tuplizer…???…can’t remember exactly) are querying those values when > performing reflection based stuff, and if not done from web/app config, the > “NH infrastructure components” will receive the default values, and the code > will then throw under medium trust > > > > HTH > > Morten > > > > P.S. > > > > See static ctor in Environment type that calls > LoadGlobalPropertiesFromAppConfig. This is the only place (I believe) where > Environment.UseReflectionOptimizer is initialized. Also check out where > Environment.UseReflectionOptimizer is queried. > > > > > ------------------------------ > > *From:* [email protected] [mailto:[email protected]] *On > Behalf Of *Fabio Maulo > *Sent:* Wednesday, October 07, 2009 11:11 PM > *To:* [email protected] > > *Subject:* [nhusers] Re: Having medium trust issues > > > > That is configurable through app/web config. > > <configSections> > > <section > name="hibernate-configuration" > type="NHibernate.Cfg.ConfigurationSectionHandler, > NHibernate" /> > > </configSections> > > > > <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> > > <reflection-optimizer > use="false"/> > > </hibernate-configuration> > > > > in this case you should use the Configure method, overload with file name, > to upload the other part of the configuration.... > > well or any other part coming from anywhere... right now I think that NH > has at least 10 ways to be configured. > > > > 2009/10/7 Tomasz Modelski <[email protected]> > > > In one of my latest projects I've managed to run NHibernate in medium > trust environment. > I've pre-generated lazy loading proxies. > > See my blog post for refenerce: > > http://it.tmod.pl/Blog/EntryId/145/NHibernate-Transparent-pre-generation-of-lazy-loading-proxies-in-Visual-Studio.aspx > > I need to do: > - pre-generate proxies (as in blog post) > - set in NHibenrate configuration property > "proxyfactory.factory_class" with correct value : > "CastleStaticProxyFactoryFactory, AssemblyNameWithoutDotDll" > - set in code NHibernate.Cfg.Environment.UseReflectionOptimizer = > false; (UseReflectionOptimizer is not configuration file property). > > As I remember that's all. > > regards, Tomasz Modelski > http://it.tmod.pl > > > On Oct 6, 2:45 pm, John Polling <[email protected]> wrote: > > Hi Morten, > > > > Thanks, but I've already done the -D:assembly.allow-partially-trusted- > > callers=true. > > > > John > > > > On Oct 6, 1:12 pm, "Morten Maxild" <[email protected]> wrote: > > > > > Use Reflector to see if Castle was build with APTCA attribute. Don't > know about the official distro about APCTA. > > > > > Otherwise if you build from source use this with nant: > '-D:assembly.allow-partially-trusted-callers=true' > > > > > All signed assemblies needs APTCA attribute to work in medium trust. > > > > > HTH > > > Morten > > > > > >-----Original Message----- > > > >From: [email protected] [mailto:[email protected]] On > Behalf > > > >Of John > > > >Sent: Tuesday, October 06, 2009 11:39 AM > > > >To: nhusers > > > >Subject: [nhusers] Having medium trust issues > > > > > >Hi, > > > > > >My existing hosting company has suddenly switched to a medium trust > > > >setup. I'm using the latest build from Castle and I've gone through a > > > >number of issues with that. (http://groups.google.com/group/castle- > > > >project-users/browse_thread/thread/98937c21efa854de) > > > > > >I've managed to progress things, with the help of the Castle team > > > >however I'm now getting the following error and was wondering if > > > >anyone here has managed to get the NHibernate side of things working > > > >on medium trust. > > > > > >I've set the ActiveRecord / NHibernate settings as described here > > > >http://nhforge.org/wikis/howtonh/run-in-medium-trust.aspx > > > > > >Has anyone got any further than this? > > > > > >Here is the error I'm getting: > > > > > > 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.] > > > > System.Security.CodeAccessSecurityEngine.ThrowSecurityException > > > >(Assembly asm, PermissionSet granted, PermissionSet refused, > > > >RuntimeMethodHandle rmh, SecurityAction action, Object demand, > > > >IPermission permThatFailed) +150 > > > > System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean > > > >publicOnly, Boolean noCheck, Boolean& canBeCached, > > > >RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0 > > > > System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean > > > >fillCache) +86 > > > > System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean > > > >skipVisibilityChecks, Boolean fillCache) +230 > > > > System.Activator.CreateInstance(Type type, Boolean nonPublic) +67 > > > > NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type > > > >type) +8 > > > > NHibernate.Driver.ReflectionBasedDriver.CreateConnection() +28 > > > > NHibernate.Connection.DriverConnectionProvider.GetConnection() +56 > > > > > > >NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare > > > >() +15 > > > > NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords > > > >(Dialect dialect, IConnectionHelper connectionHelper) +65 > > > > NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update > > > >(ISessionFactory sessionFactory) +80 > > > > NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, > > > >IMapping mapping, Settings settings, EventListeners listeners) +599 > > > > NHibernate.Cfg.Configuration.BuildSessionFactory() +87 > > > > > >Castle.ActiveRecord.Framework.SessionFactoryHolder.GetSessionFactory > > > >(Type type) +465 > > > > Castle.ActiveRecord.Framework.SessionFactoryHolder.CreateSession > > > >(Type type) +126 > > > > Castle.ActiveRecord.ActiveRecordBase.FindAll(Type targetType, Order > > > >[] orders, ICriterion[] criteria) +117 > > > > Castle.ActiveRecord.ActiveRecordBase`1.FindAll(Order order, > > > >ICriterion[] criteria) +129 > > > > Syncmaster.Models.NewsItem.FindTop(Int32 i) +112 > > > > Syncmaster.Controllers.HomeController.Index() +55 > > > > > >Thanks in advance > > > > > >John > > > > > -- > Fabio Maulo > > > > > > -- 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 -~----------~----~----~----~------~----~------~--~---
