Run in Medium Trust

Apr 17, 2011 at 1:20 PM

Hi,

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

Thanks

Anurag

Coordinator
Apr 18, 2011 at 6:06 AM

Have a look at this thread...

http://epplus.codeplex.com/discussions/249961

Jan

Apr 19, 2011 at 4:10 AM
Edited Apr 19, 2011 at 4: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.

Thanks

Anurag

Apr 19, 2011 at 8:47 AM

Hi,

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

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);
                    //}
                    //else
                    //{
                    //    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=2.8.0.1, Culture=Neutral, PublicKeyToken=ea159fdaa78159a1"  />

 

That's all.

Good work, Ivano

Apr 19, 2011 at 5:12 PM

Hi,

Thanks for the detailed instructions. Everything worked.

Anurag