This project is read-only.
1
Vote

[SecurityException: That assembly does not allow partially trusted callers.] for NotesForGallery 2.0

description

Hello all. In my local environment NotesForGallery2.0 works fine. Very impressive to, it is awesome, kudos to codeplex. However, when I run it from GoDaddy's servers I get:
[SecurityException: That assembly does not allow partially trusted callers.]
I put in a ticket with GoDaddy. They responded:
Our ASP.NET 3.5 shared hosting servers use the default Medium trust level.
I did some research and found out that, at least the way I understand it is that <assembly: System.Security.AllowPartiallyTrustedCallersAttribute()>
is needed to run in a medium security environment.(Which is what GoDaddy and Framework 3.5 require as default).
I downloaded the NotesForGallery2.0 Source Code and added
using System.Security;
[assembly: AllowPartiallyTrustedCallers]
to the NotesForGalley\Properties\AssemblyInfo.cs file.
Then copied the whole source code folder to a folder in my root of my site and got the same message. I also commented out
<authentication mode="Windows"/>
because that was the first error I got.
 
Any ideas. I think I am running uphill because If GoDaddy has there server set to medium trust level, I am not sure I can get around it, but I know there is a lot of ppl out there that know a whole lot more than me. If your one of those ppl, please help!!!!
 
Here is my whole error page:
 

Server Error in '/' 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 23: </asp:ScriptManager>
Line 24: <b style="font-size: 110%;">Gallery #1</b>
Line 25: <ctl:Gallery runat="server" ID="Gallery1" FolderUrl="~/Images/1" Size="100" />
Line 26: </div>
Line 27: </asp:Content>

 
Source File: d:\hosting\avoytas\NotesForGallery\TestNotesForGallery\Default.aspx Line: 25
 
Stack Trace:
 
 
[SecurityException: That assembly does not allow partially trusted callers.]
ASP.notesforgallery_testnotesforgallery_default_aspx.__BuildControlGallery1() in d:\hosting\avoytas\NotesForGallery\TestNotesForGallery\Default.aspx:25
ASP.notesforgallery_testnotesforgallery_default_aspx.__BuildControlContent2(Control __ctrl) in d:\hosting\avoytas\NotesForGallery\TestNotesForGallery\Default.aspx:20
System.Web.UI.CompiledTemplateBuilder.InstantiateIn(Control container) +12
ASP.masterpage_master.__BuildControlContentPlaceHolder1() in d:\hosting\avoytas\MasterPage.master:43
ASP.masterpage_master.__BuildControlform1() in d:\hosting\avoytas\MasterPage.master:11
ASP.masterpage_master.__BuildControlTree(masterpage_master __ctrl) in d:\hosting\avoytas\MasterPage.master:1
ASP.masterpage_master.FrameworkInitialize() in d:\hosting\avoytas\MasterPage.master.cs:912308
System.Web.UI.UserControl.InitializeAsUserControlInternal() +35
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8665071
System.Web.UI.Page.get_Master() +51
System.Web.UI.Page.ApplyMasterPage() +15
System.Web.UI.Page.PerformPreInit() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6785
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +242
System.Web.UI.Page.ProcessRequest() +80
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.notesforgallery_testnotesforgallery_default_aspx.ProcessRequest(HttpContext context) in App_Web_bsp-qdj9.4.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
 

 

 

Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3053

comments

himanshudhami wrote Sep 29, 2010 at 7:50 AM

Replace this in Gallery.cs:

//System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
         //if (di.Exists)
         //{
         //    foreach (System.IO.FileInfo fi in di.GetFiles())
         //    {
         //        string extension = fi.Extension.ToLower();
         //        if (extension == ".jpg" || extension == ".gif" || extension == ".png")
         //            fileNames.Add(fi.Name);
         //    }
         //}
with
if (Directory.Exists(path))
         {
             foreach (string filename in Directory.GetFiles(path, "*.JPG"))
             {
                 string tmp=filename.Substring(filename.LastIndexOf("\\")).Replace("\\","");
                 fileNames.Add(tmp);
             }

         }
it works fine after that

SouthendSupporter wrote Jan 7, 2011 at 12:39 PM

Might this fix aslo resolve the issue I am having with thumbnails not generating??
http://notesforgallery.codeplex.com/Thread/View.aspx?ThreadId=240091

I have tried applying it as below:
{
        ScriptControlDescriptor descriptor = new ScriptControlDescriptor("NotesFor.Gallery", this.ClientID);
        string path = HttpContext.Current.Server.MapPath(FolderUrl);
        // System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(path);
        List<string> fileNames = new List<string>();
        //if (di.Exists)
        //{
        //foreach (System.IO.FileInfo fi in di.GetFiles())
        //{
        // string extension = fi.Extension.ToLower();
        // if (extension == ".jpg" || extension == ".gif" || extension == ".png")
        // fileNames.Add(fi.Name);
        // }
        //}

        if (Directory.Exists(path))
        {
            foreach (string filename in Directory.GetFiles(path, "*.JPG"))
            {
                string tmp = filename.Substring(filename.LastIndexOf("\\")).Replace("\\", "");
                fileNames.Add(tmp);
            }

        }
BUT I get an error 'Name Directory does not existfor directory.exists and directory.GetFilePaths??? And will thisa only work if the images are .jpgs??

wrote Feb 14, 2013 at 3:35 AM