1
Vote

System.Security.SecurityException and fix

description

For some strange reason I'm getting System.Security.SecurityException in my shared medium trust hosting provider. I've debugged and found out that error was raising in file ZipPackagePart.cs, line 157 "var fi = new FileInfo(f);".

I've applied a simple fix and it worked for me and might help others. Here's the code block:
            string f = Uri.OriginalString;
            //var fi = new FileInfo(f);
            var fiName = f.Substring(f.LastIndexOf("/") + 1);
            _rels.WriteZip(os, (string.Format("{0}_rels/{1}.rels", f.Substring(0, f.Length - fiName.Length), fiName)));
ps: I don't know if it may not cause other problems.

comments