This project has moved. For the latest updates, please go here.

Partial trust Help!!!!

Sep 17, 2008 at 9:47 PM

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 26: 			SharpMap.Layers.VectorLayer layCountries = new SharpMap.Layers.VectorLayer("Congressional Districts");
Line 27: 			//Set the datasource to a shapefile in the App_data folder
Line 28: layCountries.DataSource = new SharpMap.Data.Providers.ShapeFile(HttpContext.Current.Server.MapPath(@"~\App_data\cd99_110.shp"), true);Line 29:             SharpMap.Rendering.Thematics.GradientTheme popdens = new SharpMap.Rendering.Thematics.GradientTheme("CD", 0, 40,
Line 30:             new SharpMap.Styles.VectorStyle(), new SharpMap.Styles.VectorStyle());

Source File: d:\hosting\3135737\html\App_Code\MapHelper.cs    Line: 28

Stack Trace:

[SecurityException: That assembly does not allow partially trusted callers.]
   SharpMap.Data.Providers.ShapeFile.ParseProjection() +0
   SharpMap.Data.Providers.ShapeFile..ctor(String filename, Boolean fileBasedIndex) +215
   MapHelper.InitializeMap(Size size) in d:\hosting\3135737\html\App_Code\MapHelper.cs:28
   Ajax.Page_Load(Object sender, EventArgs e) in d:\hosting\3135737\html\Ajax.aspx.cs:17
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7350
   System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
   System.Web.UI.Page.ProcessRequest() +86
   System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
   System.Web.UI.Page.ProcessRequest(HttpContext context) +49
   ASP.ajax_aspx.ProcessRequest(HttpContext context) in App_Web_lhht5lfz.0.cs:0
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

Any Ideas would be greatly appreciated.

I extended the sample ajax page. all is well on the dev server but when I posted to Godaddy here is what I get.

Thanks in Adv.
Sep 18, 2008 at 9:41 AM
Hi wwlgray, the exception is caused because the provider is requesting write access to the file system, this is because you have fileBasedIndex = true in the constructor. You may be able to circumvent this by setting it to false but the performance will reduce. Depending on how the isp has configured the hosting account you may be able to override the trust setting by modifying the web.config see: however it is unlikely that they will let you override the trust settings. hth jd
Sep 18, 2008 at 1:08 PM
Yes, that did get me past there but now it's stopping where it writes the image to the context output stream. I am trying to get around it but I haven't figured it out yet. Thanks and if you have any more suggestions please let me know. The trust level is inherited and locked.
Sep 18, 2008 at 1:18 PM
do you have a stack trace for the new exception?