Select.Pdf: security transparent method to access security critical method

1

I am using Select.Pdf to make PDF files of pages of my angular app.

Select.Pdf is ruinning on server side in .Net.Core 4.6.2.

Here is the code which is doing the conversion

SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf();    
SelectPdf.PdfDocument doc = converter.ConvertUrl(url);
return doc.Save();

For some reason ConvertUrl method ends up with the exception listed below

System.Exception
  HResult=0x80131500
  Message=Conversion failure. Attempt by security transparent method 'SelectPdf.Lib.ស.ᜃ()' to access security critical method 'System.Runtime.InteropServices.Marshal.AllocHGlobal(Int32)' failed.

Assembly 'Select.Pdf, Version=18.4.0.0, Culture=neutral, PublicKeyToken=e0ae9f6e27a97018' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model.  Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.
  Source=Select.Pdf
  StackTrace:
   at SelectPdf.HtmlToImage.ᜀ(String A_0, ឨ[]& A_1, ឃ& A_2)
   at SelectPdf.HtmlToPdf.ᜁ(String A_0, String A_1, String A_2, String A_3, Boolean A_4)
   at SelectPdf.HtmlToPdf.ConvertUrl(String url)
   at Powel.UtilityFlow.Portal.HtmlToPdfService.SelectPdfHtmlToPdfService.GeneratePdf(String url) in C:\Projects\Powel.Dynamics365.Portal\Powel.UtilityFlow.Portal\Services\HtmlToPdfService\SelectPdfHtmlToPdfService.cs:line 41
   at Powel.UtilityFlow.Portal.Controllers.EnquiryController.generatePDF(Guid id, String url) in C:\Projects\Powel.Dynamics365.Portal\Powel.UtilityFlow.Portal\Controllers\EnquiryController.cs:line 435
   at Powel.UtilityFlow.Portal.Controllers.EnquiryController.<>c__DisplayClass16_0.<PostNewEnquiry>b__1() in C:\Projects\Powel.Dynamics365.Portal\Powel.UtilityFlow.Portal\Controllers\EnquiryController.cs:line 316
   at System.Threading.Tasks.Task.Execute()

Does anybody have any clue of what the root cause of this exception could be?

.net
pdf-generation
asked on Stack Overflow Feb 6, 2019 by Konstantin

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0