I am getting an error when I try to create an object XLWorkbook.
Code :
```
var workbook = new XLWorkbook();
```
Message that I get :
```
Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.get_UserName()
at ClosedXML.Excel.XLWorkbook..ctor(XLEventTracking eventTracking)
at XXXXXX.UI.Controls.ShowViewXXXXXX.ViewXXXXXXTableControl.ViewXXXXXXExportExcelButton_Click(Object sender, ImageClickEventArgs args) in c:\@work\XXXXXX\XXXXXX\Source\XXXXXX\App_Code\ViewXXXXXX\ShowViewXXXXXX.Controls.cs:line 89
```
I have added the next files to BIN Directory of my website :
* ClosedXML.dll (ClosedXML_Net3.5 version 0.68.1.0)
* DocumentFormat.OpenXml.dll (Open XML Format SDK 2.0 version 2.0.2022.0)
Comments: ** Comment from web user: akorff **
I had this problem. I could open a new workbook or load an existing excel file, but when I published it to production it would not open an existing excel file (only a new workbook).
After a lot of research, I found that 95% of the answer say to set your trust level to full (but unfortunately I already had it set to full on both my dev server and my production server):
In your web.config in the system.web section:
<system.web>
<trustLevel name="Full" policyFile="internal"/>
</system.web>
What solved it for me: If you have access to IIS and you are running IIS 7, find the app pool for the site, and set Load User Profile = True.