Security exception publishing to full trust

Feb 9, 2011 at 2:59 AM

Any idea why I'm getting this trying to publish to host server running in the full trust?

[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
System.Security.CodeAccessPermission.Demand() +46
System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(Type owner, StackCrawlMark& stackMark, Boolean skipVisibility) +9461551
System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Type owner, Boolean skipVisibility) +40
AutoMapper.DelegateFactory.CreateDynamicMethod(MemberInfo member, Type sourceType) +585
AutoMapper.DelegateFactory.CreateSet(PropertyInfo property) +128
AutoMapper.Internal.PropertyAccessor..ctor(PropertyInfo propertyInfo) +122
AutoMapper.ReflectionHelper.ToMemberAccessor(MemberInfo accessorCandidate) +294
AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, IMappingOptions options) +521
AutoMapper.Configuration.CreateTypeMap(Type source, Type destination, String profileName) +156
AutoMapper.Configuration.CreateMap(String profileName) +179
AutoMapper.Configuration.CreateMap() +92
AutoMapper.Mapper.CreateMap() +99
Gallery.Infrastructure.Impl.AutoMapperBootstrapper.RegisterMappings() in AutoMapperBootstrapper.cs:23
Gallery.Server.Global.Application_Start(Object sender, EventArgs e) in Global.asax.cs:17

Feb 9, 2011 at 12:07 PM

I've never seen that exception before. We do use AutoMapper in the Gallery Server code, which obviously uses reflection, but I don't think you should be getting that if you're running in full trust. Do you have your IIS app pool running ASP.Net 4.0 or 2.0?  (It should be 4.0)

Feb 9, 2011 at 3:15 PM

iis 7 .net 4 integrated full trust (internal). Do you have any suggestions on deploying it outside VS? xcopy? webdeploy? Do I need make any configuration changes? It seems to have a whole lot of "localhost" references. Xcopy definitely did not work for me on two different host servers, will try webdeploy now.

Feb 9, 2011 at 4:24 PM

Ok, here is what worked in the end:

1. Web deploy from WebMatrix to supported host. Still was getting security exceptions.

2. Set full trust in web.config. Most hosts won't let you, so I guess I got lucky here. Still was getting error, this time from activator complaining about multiple authentication methods enabled.

3. In IIS under site's authentication, left only "anonymous" (it also had basic enabled).

After these steps, all seems to work fine.

Feb 10, 2011 at 1:29 AM

Glad to hear you got it working. We have not tried Web Deploy yet, but it's good to know that it works. We just manually deployed the site when we launched it. A better deployment story is something that is planned for the future though.