Medium Trust Level

Topics: Developer Forum
Jul 3, 2008 at 9:40 PM
Is it possible to run the Basic Web Player under Medium Trust rather than Full Trust?  Any time I lower it to medium trust I get permissions errors that come from the Microsoft.LearningComponents.dll.  Any assistance would be much appreciated.
Jul 4, 2008 at 12:25 PM
This is possible but you would need to create a Code Access Security policy file to grant the Microsoft.LearningComponents.dll the rights it needs.  If you not a fairly good SharePoint developer I would probably avoid this.

You could always move the DLL into the GAC (c:\windows\assembly) as this would give the DLL full trust without raising the trust level for all assemblies.

Andrew
Jul 5, 2008 at 10:54 PM
Thanks for the information.  After looking into the error a little more it turns out it is the "Microsoft.LearningComponents.Compression.dll" that is causing my issues not the "Microsoft.LearningComponents.dll" as I earlier thought.  I am seeing if the GAC suggestion will fly.  Any other suggestions would be greatly appreciated.
Coordinator
Aug 27, 2008 at 10:58 PM
FYI, we're using reflection to call a private API for reading Zip files.  This isn't allowed in anything but full trust :-(

As Woody suggested, if you GAC Microsoft.LearningComponents.Compression.dll this should solve the problem at the expense of slightly opening yourself up for security issues if that DLL is buggy.

The other solution is to get a public partial trust Zip API into the .NET Framework.  Believe me, I've asked :-)
Oct 1, 2008 at 10:10 PM
Have you (or anyone else reading this) looked at SharpZipLib as a possible solution to this Full Trust issue?
Oct 16, 2008 at 7:57 PM
Edited Oct 16, 2008 at 8:00 PM
SharpZipLib is the answer.  I have implemented the SharpZipLib and the Compression dll now loads under medium trust. 

Here is the steps to implement this and the new code:

  1. Download SharpZipLib Source
  2. Rebuild it with a Strong Name
  3. Add Reference to the SharpZipLib.dll
  4. Add the following using statement 
    using
     
    ICSharpCode.SharpZipLib.Zip;  
  5. Replace the Unzip method code with the code below

    FastZip   fz = new FastZip();

    fz.ExtractZip(zipFile.FullName, destinationDirector.FullName, 

    "");  
     

  6. Build and enjoy

Yes, you replace all that code in the Unzip method with just 2 lines of code.  Pretty cool.