3
votes

I'm facing following problem. I've got Service Stack-based webservice which I want have on shared hosting. When deploying there and trying to open an url I'm getting following error:

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: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

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: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +34
System.Security.CodeAccessPermission.Demand() +46
System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(Module m, StackCrawlMark& stackMark, Boolean skipVisibility) +243
System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Module m, Boolean skipVisibility) +48 ServiceStack.Text.ReflectionExtensions.GetConstructorMethodToCache(Type type) +586
ServiceStack.Text.ReflectionExtensions.GetConstructorMethod(Type type) +68 ServiceStack.Text.ReflectionExtensions.CreateInstance(Type type) +8
ServiceStack.ServiceHost.ServiceController.RegisterNServiceExecutor(Type requestType, Type serviceType, ITypeFactory serviceFactoryFn) +123
ServiceStack.ServiceHost.ServiceController.RegisterNService(ITypeFactory serviceFactoryFn, Type serviceType) +287
ServiceStack.ServiceHost.ServiceController.Register(ITypeFactory serviceFactoryFn) +96
ServiceStack.ServiceHost.ServiceManager.Init() +50
ServiceStack.WebHost.Endpoints.AppHostBase.Init() +43
DarkMindFx.Global.Application_Start(Object sender, EventArgs e) +571

So it seems like ServiceStack cannot perform the reflaction. I've also tried to

<securityPolicy>
        <trustLevel name="Full" policyFile="internal"/>
</securityPolicy>

to web.config but as the result hosting returns me an error with this line in web.config. Does anyone ever faced such issue? Any ideas how to solve it?

1
OK, I have figured out how to make it working. It looks like the poblem was in ServiceStack - first I had version 4.0, but then removed and installed 3.9.71. It seems like I didn't manage to do it correctly and there was some kind of mixture of libraries and packages in my project. So when I've implemented a web app from the scrath everything became rainbows and unicorns.user2484670

1 Answers

1
votes

The SecurityException is because GoDaddy doesn't support full trust ASP.NET hosting. You can try requesting their support to enable it for your site, otherwise you would need to use a different hosting provider.