title: Why does Gembox spreadsheet crash when calling Excelfile.save: FileNotFoundException Could not load file or assembly System.Security.Permissions
body: <p>I am using Gembox to open, modify and save a xlsx file. Calling Save on the Excelfile causes a System.IO.FileNotFoundException.</p>
  
  <p>The problem happens with our company serial key and with the free key.</p>
  
  <p><strong>Sample Code</strong></p>
  
  <pre><code>using GemBox.Spreadsheet;
  namespace ConsoleApp
  {
      class Program
      {
          static void Main(string[] args)
          { 
              var path = @"C:\code\GemboxTest\App.xlsx"; 
              SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
              ExcelFile ef = ExcelFile.Load(path); 
              ExcelWorksheet ws = ef.Worksheets[0]; 
              //ws.Columns[0].Cells[0].Value = 42; 
              ef.Save(path); // &lt;--------------------------------- Crash!
          }
      }
  }
  </code></pre>
  
  <p><strong>Error message</strong></p>
  
  <pre><code>Could not load file or assembly 'System.Security.Permissions, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
  System.Security.Permissions, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
  </code></pre>
  
  <p><strong>Stacktrace</strong></p>
  
  <pre><code>at   .(Stream , Byte[] , Int32 , Int32 , String )
  at   .(Stream )
  at   .(Stream )
  at   . ()
  at   .(Stream )
  at    .Dispose()
  at   .   ​ (Boolean )
  at   .Dispose()
  at    .    ​ ()
  at    .(Boolean )
  at    .Dispose()
  at GemBox.Spreadsheet.XlsxSaveOptions.(ExcelFile , Stream ,     )
  at GemBox.Spreadsheet.XlsxSaveOptions.Save(ExcelFile excelFile, Stream stream, String path)
  at GemBox.Spreadsheet.SaveOptions.(ExcelFile , String )
  at GemBox.Spreadsheet.ExcelFile.Save(String path, SaveOptions options)
  at GemBox.Spreadsheet.ExcelFile.Save(String path)
  at ConsoleApp.Program.Main(String[] args) in C:\code\GemboxTest\ConsoleApp\Program.cs:line 14
  </code></pre>
  
  <p><strong>Versions</strong></p>
  
  <ol>
  <li>.NET Core 3.1 (also fails with 3.0)</li>
  <li>GemBox.Spreadsheet Version=45.0.1131 </li>
  <li>Visual Studio 2019 (VisualStudioVersion = 16.0.29905.134) </li>
  <li>Windows 10 pro 64bit</li>
  </ol>
  
  <p><strong>Sample csproj file</strong></p>
  
  <pre><code>&lt;Project Sdk="Microsoft.NET.Sdk"&gt;
  &lt;PropertyGroup&gt;
  &lt;OutputType&gt;Exe&lt;/OutputType&gt;
  &lt;TargetFramework&gt;netcoreapp3.1&lt;/TargetFramework&gt;
  &lt;/PropertyGroup&gt;
  &lt;ItemGroup&gt;
  &lt;PackageReference Include="GemBox.Spreadsheet" Version="45.0.1131" /&gt;
  &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>