Re: [sm-users] Has anyone got structuremap working in medium trust (shared hosting environment)?

30 views
Skip to first unread message

Jeremy D. Miller

unread,
Nov 30, 2008, 11:58:23 AM11/30/08
to structure...@googlegroups.com
Can you give me more details on the SecurityException?  Are you trying to use Xml configuration in external files?  There shouldn't be any major issues with .Net 3.5, medium trust, and StructureMap 2.5.
 
Jeremy D. Miller
The Shade Tree Developer
jeremy...@yahoo.com



From: stevehodgkiss <st...@hodgkiss.me.uk>
To: structuremap-users <structure...@googlegroups.com>
Sent: Wednesday, November 19, 2008 6:44:58 AM
Subject: [sm-users] Has anyone got structuremap working in medium trust (shared hosting environment)?


I get a SecurityException when using structuremap 2.5 in medium trust.

kleneau

unread,
Dec 18, 2008, 4:24:26 PM12/18/08
to structuremap-users
I am attempting just this. I have tried setting the trust level in my
web.config to medium in order to simulate my hosting provider. When
the application starts up I receive a policy exception.
(System.Security.SecurityException: That assembly does not allow
partially trusted callers.) Any help will be greatly appreciated, I
have searched the web and haven't found much.

Background: App is an MVC Beta web app. Bootstrapper config that is
executed at application_start. .Net 3.5 and StructureMap 2.5. App is
starting up in VS 2008 internal web server and the trust level is set
in the web.config.

Thanks,
Kyle

On Nov 30, 10:58 am, "Jeremy D. Miller" <jeremydmil...@yahoo.com>
wrote:
> Can you give me more details on the SecurityException?  Are you trying to use Xml configuration in external files?  There shouldn't be any major issues with .Net 3.5, medium trust, and StructureMap 2.5.
>
>  Jeremy D. Miller
> The Shade Tree Developer
> jeremydmil...@yahoo.com

Jeremy D. Miller

unread,
Dec 18, 2008, 4:58:33 PM12/18/08
to structure...@googlegroups.com
I researched that one a bit.  From the documentation, I just need to add an attribute at the assembly level

 
Jeremy D. Miller
The Shade Tree Developer
jeremy...@yahoo.com



From: kleneau <k.le...@gmail.com>
To: structuremap-users <structure...@googlegroups.com>
Sent: Thursday, December 18, 2008 3:24:26 PM
Subject: [sm-users] Re: Has anyone got structuremap working in medium trust (shared hosting environment)?

Kyle Leneau

unread,
Dec 18, 2008, 5:11:06 PM12/18/08
to structure...@googlegroups.com
Is there any time frame for this?  Or should/can I get the SM source and add the attribute and build for my need?

Jeremy D. Miller

unread,
Dec 18, 2008, 5:13:44 PM12/18/08
to structure...@googlegroups.com
At this point, I'm thinking the first week in January.  You've always got the ability to change the code in any way you see fit.  Please do post the patch if you change things.


From: Kyle Leneau <k.le...@gmail.com>
To: structure...@googlegroups.com
Sent: Thursday, December 18, 2008 4:11:06 PM

Kyle Leneau

unread,
Dec 19, 2008, 10:34:05 PM12/19/08
to structure...@googlegroups.com
I think the trust issue goes further than just an atribute on the assebly.  I was able to add this line to the version target in the build script:  <attribute asis="true" type="AllowPartiallyTrustedCallersAttribute" />  Along with an import statement of: <import namespace="System.Security" />  in order to build the CommonAssembly.cs file.

I was able to update my project with the newly created dll and managed to get past the generic security exception only to be greeted with the following below.


[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessPermission.Demand() +59
   System.IO.Directory.GetCurrentDirectory() +182
   System.Reflection.Emit.AssemblyBuilderData..ctor(Assembly assembly, String strAssemblyName, AssemblyBuilderAccess access, String dir) +1698440
   System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) +327
   System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) +38
   StructureMap.Emitting.DynamicAssembly.Init() +184
   StructureMap.Emitting.InstanceBuilderAssembly..ctor(IEnumerable`1 plugins) +141
   StructureMap.Graph.PluginCache.createAndStoreBuilders(IEnumerable`1 plugins) +146
   StructureMap.Graph.PluginCache.Compile() +125
   StructureMap.Container.construct(PluginGraph pluginGraph) +118
   StructureMap.Container..ctor(PluginGraph pluginGraph) +5
   StructureMap.ObjectFactory.Initialize(Action`1 action) +130
   PertNear.WWW.Bootstrapper.ConfigureStructureMap() +82
   PertNear.WWW.Global.Application_Start(Object sender, EventArgs e) +46
Reply all
Reply to author
Forward
0 new messages