This project has moved and is read-only. For the latest updates, please go here.

Run in Medium Trust

Apr 17, 2011 at 2:20 PM


How can I run the dll, in an medium trust environment. My hosting provider supports only medium trust.



Apr 18, 2011 at 7:06 AM

Have a look at this thread...


Apr 19, 2011 at 5:10 AM
Edited Apr 19, 2011 at 5:11 AM

Hi Jan,

I have reviewed the same, but seem to be missing something. I have opened "EPPlus.csproj" in VS2008, made the changes. I have then added a new web project to the solution, added a reference to EPPlus project, but cannot use the same i.e. "OpenOfficeXml.ExcelPackage" is not found.

Help in this regard would be appreciated.



Apr 19, 2011 at 9:47 AM


These are the steps required to run in EPPLus in medium trust (tested with EPPlus

1) Download the sourcecode and open in visual studio 2008 the solutions. Locate and open the file ExcelPackage.cs in EPPlus project

2) At line 300 and at line 339 comment all the catch expression

                     //if (password == null && EncryptedPackageHandler.StgIsStorageFile(template.FullName)==0)
                    //    throw new Exception("Can not open the package. Package is an OLE compound document. If this is an encrypted package, please supply the password", ex);
                    //    throw (ex);

3) Open the file AssemblyInfo.cs located in EPPlus/Properties  and add the following line after [assembly: ComVisible(false)]

[assembly: AllowPartiallyTrustedCallers]

4) Compile the solution and take the builded EPPLus.dll

5) On the web.config add the following line in the  <assemblies> section:

 <add assembly="EPPlus, Version=, Culture=Neutral, PublicKeyToken=ea159fdaa78159a1"  />


That's all.

Good work, Ivano

Apr 19, 2011 at 6:12 PM


Thanks for the detailed instructions. Everything worked.