ReadyToRunコンパイルを使用

This article was translated from English: Does it need improvement?
Translated
View the article in English

有効化 ReadyToRun コンパイル IronPdfの導入中に改ざん防止が作動し、次の例外が発生します。

Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronPdf, Version=2024.2.0.2, Culture=neutral, PublicKeyToken=94e1c31412563c75 assembly is not authentic. Please try to reinstall the nuget package
   at IronPdf.PdfDocument.uswvws(Boolean vhfwdf)
   at IronPdf.PdfDocument.get_BinaryData()
   at IronPdf.PdfDocument.SaveAs(String FileName, Boolean SaveAsRevision)
   at Program.<Main>$(String [] args) in C:\csharppro\aottest\aottest\Program.cs:line 5

理由

Microsoftのドキュメントによると、SDKはアプリケーションとともに配布されるアセンブリを事前コンパイルします。 自己完結型アプリケーションの場合、このアセンブリセットにはフレームワークが含まれます。 C++/CLI のバイナリは ReadyToRun のコンパイル対象とはなりませんのでご注意ください。

ソリューション

ReadyToRun処理から特定のアセンブリを除外するには、次を使用します リスト.

<ItemGroup>
    <PublishReadyToRunExclude Include="IronPdf.dll" />
</ItemGroup>
XML