OK, I think I figured out what is going on and what my solution is.
The short answer is: back to LinFu
Greg and John, thank you for pointing me in the right direction.

The long answer, if you're interested...
By default asp.net runs in full trust mode. (http://msdn.microsoft.com/
en-us/library/tkscy493.aspx) I'm sure my apps are running full trust
because I configure IIS and I haven't changed this.

The next thing to consider is user access. I use windows
authentication and impersonation. If I understand this article (http://
www.bluevisionsoftware.com/WebSite/TipsAndTricksDetails.aspx?Name=AspNetAccount)
then the user's credentials are used to execute the code, not the
Network Service account. I think this is where DP is failing because
it works for me, but not the end users. If I wasn't using windows
impersonation the code would execute without fail because the network
service account would be able to generate the DPs.

So if I can't change the environment I need to change the code. I came
across 2 posts which described how to go about thsi(http://
blog.yeticode.co.uk/2010/03/running-nhibernate-in-medium-trust/ and
http://groups.google.com/group/castle-project-users/browse_thread/thread/2451ef352523865f?hl=en&pli=1).
I would need a private build of castle core, pd and nh which includes
APTC.

following the links I came to
http://groups.google.com/group/castle-project-devel/browse_thread/thread/33a891ce7da71225/f6bd971e33a54a9c
which outlines why DP does not APTC by default.

With this information I decided it's better to accept the additional
reference of another 3rd party, then manage my own private castle
builds.

On Jan 9, 10:13 am, Jason Meckley <[email protected]> wrote:
> thanks John. I just need to figure out how then.
>
> On Jan 8, 8:10 am, John Davidson <[email protected]> wrote:
>
> > It is possible to change the privileges allowed in the environment, but the
> > mechanisms to do so are slightly different depending upon IIS version and
> > ASP.Net versions. If you are running in an enterprise environment the 'web
> > master' _should_ be able to assist, as they reduced the security privileges
> > from full to what you are currently experiencing. Although they may
> > arbitrarily say that security is fixed and unchangeable - then you have a
> > problem.
>
> > John Davidson
>
> > On Fri, Jan 7, 2011 at 7:40 PM, Jason Meckley <[email protected]>wrote:
>
> > > Is there a way to elevate the users privileges? or the environments
> > > privileges?
>
> > > On Jan 7, 5:00 pm, Greg Young <[email protected]> wrote:
> > > > because its building the proxy that needs the elevated privs? after
> > > > its built you wouldnt need the privs just to access the existing built
> > > > type.
>
> > > > On Fri, Jan 7, 2011 at 4:54 PM, Jason Meckley <[email protected]>
> > > wrote:
> > > > > another observation.
>
> > > > > If I access a webpage that uses lazy loading everything works for me.
> > > > > The non-admin user could then access that same page and it works for
> > > > > him/her.
> > > > > If a non-admin accesses a webpage that users lazy loading the page
> > > > > won't load (errors). If I then access the page it works and it will
> > > > > start working for the non-admin until the application stops.
>
> > > > > If figure this has to do with NH being "lazy" about things and doesn't
> > > > > spin up dynamic proxies until they are actually needed. But why would
> > > > > it work for non-admins after I access the proxy?
>
> > > > > On Jan 7, 4:45 pm, Jason Meckley <[email protected]> wrote:
> > > > >> I thought the castle proxy issue was fixed with NH3?
>
> > > > >> We are running into this issue in our test environment.
> > > > >> NH 3
> > > > >> Castle core, monorail, windsor 2.5
> > > > >> automapper
> > > > >> my project targets .net 4.0
>
> > > > >> With 2.1 I used LinFu for proxies because Castle was throwing this
> > > > >> error. With 3.0 I replaced LinFu with Castle to reduce the number of
> > > > >> dependencies.
>
> > > > >> The system runs fine locally and I can access the test environment 
> > > > >> and
> > > > >> not get this error. However my non-admin users are getting a blank
> > > > >> page, or no feedback from an ajax call, when a proxy call is
> > > > >> attempted.
>
> > > > >> The servers are on my companies intranet. AFAIK we are using the
> > > > >> default trust settings. Nobody has adjusted them. I am using NH 3.0
> > > > >> and castle proxies on a webforms project to use lazy properties and
> > > > >> that system is running without errors.
>
> > > > >> How can I confirm the trust settings are set to FULL on the web
> > > > >> server?
>
> > > > >> As a last resort I could switch back to LinFu, but I would prefer to
> > > > >> use a single proxy library if possible.
>
> > > > >> here is the stack trace
>
> > > > >> 2011-01-07 16:17:27,436 [9] ERROR
> > > > >> NHibernate.ByteCode.Castle.ProxyFactory [(null)] - Creating a proxy
> > > > >> instance failed
>
> > > > >> System.ArgumentException: Unable to obtain public key for
> > > > >> StrongNameKeyPair.
> > > > >>    at System.Reflection.StrongNameKeyPair.ComputePublicKey()
> > > > >>    at System.Reflection.StrongNameKeyPair.get_PublicKey()
> > > > >>    at System.Reflection.Emit.AssemblyBuilder..ctor(AppDomain domain,
> > > > >> AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence
> > > > >> evidence, PermissionSet requiredPermissions, PermissionSet
> > > > >> optionalPermissions, PermissionSet refusedPermissions, 
> > > > >> StackCrawlMark&
> > > > >> stackMark, IEnumerable`1 unsafeAssemblyAttributes,
> > > > >> SecurityContextSource securityContextSource)
> > > > >>    at
>
> > > System.Reflection.Emit.AssemblyBuilder.InternalDefineDynamicAssembly(AssemblyName
> > > > >> name, AssemblyBuilderAccess access, String dir, Evidence evidence,
> > > > >> PermissionSet requiredPermissions, PermissionSet optionalPermissions,
> > > > >> PermissionSet refusedPermissions, StackCrawlMark& stackMark,
> > > > >> IEnumerable`1 unsafeAssemblyAttributes, SecurityContextSource
> > > > >> securityContextSource)
> > > > >>    at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName
> > > > >> name, AssemblyBuilderAccess access, String dir, Evidence evidence,
> > > > >> PermissionSet requiredPermissions, PermissionSet optionalPermissions,
> > > > >> PermissionSet refusedPermissions, StackCrawlMark& stackMark,
> > > > >> IEnumerable`1 assemblyAttributes, SecurityContextSource
> > > > >> securityContextSource)
> > > > >>    at System.AppDomain.DefineDynamicAssembly(AssemblyName name,
> > > > >> AssemblyBuilderAccess access)
> > > > >>    at Castle.DynamicProxy.ModuleScope.CreateModule(Boolean
> > > > >> signStrongName)
> > > > >>    at
> > > > >> Castle.DynamicProxy.ModuleScope.ObtainDynamicModuleWithStrongName()
> > > > >>    at Castle.DynamicProxy.ModuleScope.DefineType(Boolean
> > > > >> inSignedModulePreferably, String name, TypeAttributes flags)
> > > > >>    at
> > > > >> Castle.DynamicProxy.Generators.Emitters.ClassEmitter..ctor(ModuleScope
> > > > >> modulescope, String name, Type baseType, IEnumerable`1 interfaces,
> > > > >> TypeAttributes flags, Boolean forceUnsigned)
> > > > >>    at
>
> > > Castle.DynamicProxy.Generators.InvocationTypeGenerator.GetEmitter(ClassEmitter
> > > > >> class, Type[] interfaces, INamingScope namingScope, MethodInfo
> > > > >> methodInfo)
> > > > >>    at
>
> > > Castle.DynamicProxy.Generators.InvocationTypeGenerator.Generate(ClassEmitter
> > > > >> class, ProxyGenerationOptions options, INamingScope namingScope)
> > > > >>    at
>
> > > Castle.DynamicProxy.Contributors.ClassProxyTargetContributor.BuildInvocationType(MetaMethod
> > > > >> method, ClassEmitter class, ProxyGenerationOptions options)
> > > > >>    at
>
> > > Castle.DynamicProxy.Contributors.ClassProxyTargetContributor.GetMethodGenerator(MetaMethod
> > > > >> method, ClassEmitter class, ProxyGenerationOptions options,
> > > > >> OverrideMethodDelegate overrideMethod)
> > > > >>    at
>
> > > Castle.DynamicProxy.Contributors.CompositeTypeContributor.ImplementMethod(MetaMethod
> > > > >> method, ClassEmitter class, ProxyGenerationOptions options,
> > > > >> OverrideMethodDelegate overrideMethod)
> > > > >>    at
>
> > > Castle.DynamicProxy.Contributors.CompositeTypeContributor.Generate(ClassEmitter
> > > > >> class, ProxyGenerationOptions options)
> > > > >>    at
> > > > >> Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateType(String
> > > > >> name, Type[] interfaces, INamingScope namingScope)
> > > > >>    at
>
> > > Castle.DynamicProxy.Generators.ClassProxyGenerator.<>c__DisplayClass1.<GenerateCode>b__0(String
> > > > >> n, INamingScope s)
> > > > >>    at
>
> > > Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(CacheKey
> > > > >> cacheKey, Func`3 factory)
> > > > >>    at
> > > > >> Castle.DynamicProxy.Generators.ClassProxyGenerator.GenerateCode(Type[]
> > > > >> interfaces, ProxyGenerationOptions options)
> > > > >>    at
> > > > >> Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxyType(Type
> > > > >> classToProxy, Type[] additionalInterfacesToProxy,
> > > > >> ProxyGenerationOptions options)
> > > > >>    at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type
> > > > >> classToProxy, Type[] additionalInterfacesToProxy,
> > > > >> ProxyGenerationOptions options, Object[] constructorArguments,
> > > > >> IInterceptor[] interceptors)
> > > > >>    at NHibernate.ByteCode.Castle.ProxyFactory.GetProxy(Object id,
> > > > >> ISessionImplementor session)
>
> > > > >> 2011-01-07 16:17:27,529 [9] ERROR
> > > > >> MacolaDbaseConnector.Web.Controllers.GeneralRescueController [(null)]
> > > > >> - Trying to map
>
> > > System.Collections.Generic.IEnumerable`1[[MacolaDbaseConnector.Domain.Location,
> > > > >> MacolaDbaseConnector.Domain, Version=1.0.0.0, Culture=neutral,
> > > > >> PublicKeyToken=null]] to
> > > > >> MacolaDbaseConnector.Web.Model.LocationLookup[].
> > > > >> Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
>
> > > > >> AutoMapper.AutoMapperMappingException: Trying to map
>
> > > System.Collections.Generic.IEnumerable`1[[MacolaDbaseConnector.Domain.Location,
> > > > >> MacolaDbaseConnector.Domain, Version=1.0.0.0, Culture=neutral,
> > > > >> PublicKeyToken=null]] to
> > > > >> MacolaDbaseConnector.Web.Model.LocationLookup[].
> > > > >> Exception of type 'AutoMapper.AutoMapperMappingException' was thrown.
> > > > >> ---> NHibernate.HibernateException: Creating a proxy instance failed
> > > > >> ---> System.ArgumentException: Unable to obtain public key for
> > > > >> StrongNameKeyPair.
> > > > >>    at System.Reflection.StrongNameKeyPair.ComputePublicKey()
> > > > >>    at System.Reflection.StrongNameKeyPair.get_PublicKey()
> > > > >>    at System.Reflection.Emit.AssemblyBuilder..ctor(AppDomain domain,
> > > > >> AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence
> > > > >> evidence, PermissionSet requiredPermissions, PermissionSet
> > > > >> optionalPermissions, PermissionSet refusedPermissions, 
> > > > >> StackCrawlMark&
> > > > >> stackMark, IEnumerable`1 unsafeAssemblyAttributes,
> > > > >> SecurityContextSource securityContextSource)
> > > > >>    at
>
> > > System.Reflection.Emit.AssemblyBuilder.InternalDefineDynamicAssembly(AssemblyName
> > > > >> name, AssemblyBuilderAccess access, String dir, Evidence evidence,
> > > > >> PermissionSet requiredPermissions, PermissionSet optionalPermissions,
> > > > >> PermissionSet refusedPermissions, StackCrawlMark& stackMark,
> > > > >> IEnumerable`1 unsafeAssemblyAttributes, SecurityContextSource
> > > > >> securityContextSource)
> > > > >>    at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName
> > > > >> name, AssemblyBuilderAccess access, String dir, Evidence
>
> ...
>
> 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].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to