System.Security.SecurityException: That assembly does not allow partially trusted callers.

Feb 9, 2011 at 11:43 PM

When click "Manage my contributions" on "Contributions" tab, getting this error, even running locally in WebMatrix.

Server Error in '/gallery' Application.

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:

Line 87:                 }
Line 88: }
Line 89: }
Line 90:
Line 91: public IEnumerable<PackageLogEntry> GetNewPackageLogs(int lastPackageLogId) {


Source File: e:\web\rturnet0\gallery\Modules\Orchard.Gallery\Impl\GalleryPackageService.cs    Line: 89

Stack Trace:

[SecurityException: That assembly does not allow partially trusted callers.]
Orchard.Gallery.Impl.GalleryPackageService.GetUnpublishedPackages(IEnumerable`1 packageIDs, Guid accessKey) in e:\web\rturnet0\gallery\Modules\Orchard.Gallery\Impl\GalleryPackageService.cs:89
Orchard.Gallery.Controllers.ContributeController.GetUserUnpublishedPackages(Int32 userId, Userkey key) in e:\web\rturnet0\gallery\Modules\Orchard.Gallery\Controllers\ContributeController.cs:119
Orchard.Gallery.Controllers.ContributeController.MyPackages(PagerParameters pagerParameters) in e:\web\rturnet0\gallery\Modules\Orchard.Gallery\Controllers\ContributeController.cs:87
lambda_method(Closure , ControllerBase , Object[] ) +86
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +188
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +267
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +267
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +267
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +190
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +329
System.Web.Mvc.Controller.ExecuteCore() +115
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +94
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +31
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +23
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +59
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in ShellRoute.cs:155
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184



Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1

Developer
Feb 9, 2011 at 11:53 PM

Make sure you run the Orchard site in full trust (there is a note in the readme). In web.config, set <trust level="full" />

Feb 10, 2011 at 12:17 AM

Yep, that fixed it - thanks! I have that change initially, but then lost after editing and re-publishing config file.

Unrelated question, may be also something known - I'm running into annoying little issue on hosting server, works fine on locally. User authentication expires every 15 seconds or so and I have to re-login. I tried to increment timeout on forms cookie, but it has no effect. Does Orchard uses something besides cookie that can expire and invalidate session?

Developer
Feb 10, 2011 at 12:21 AM

I haven't seen this. Maybe someone else will have ideas.

Coordinator
Feb 10, 2011 at 2:42 AM

I've never seen that behavior either. As far as I know, Orchard just uses regular forms authentication.

As for the full trust issue, the reason the gallery currently requires full trust is our use of the Microsoft.Http assembly for making calls to the REST services on Gallery Server. That assembly unfortunately requires full trust. Hopefully we'll be able to update that to something newer that doesn't have that restriction in the future, or perhaps switch to something else like RestSharp.

Coordinator
Feb 10, 2011 at 7:11 AM

Never heard that too ... and never seen that. What hosting services are you using ? I will have some time allocated to work on hosting scenarios. I could see it with you and also check if it happens on other hosting providers.

 

Jun 24, 2011 at 7:08 PM

I had the same issue, changing the setting to   <trust level="Full"/> resolved the issue  

 

  

 

 

 

Feb 1, 2012 at 6:31 PM

I am trying to using Locaweb to host my site but is impossible, I change the trust level to full but IT guys from company, told me that I cant use. Someone have another idea to help me?