PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:50 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: .NET 8 AOT support
PostPosted: Tue Dec 26, 2023 12:44 pm 
Offline

Joined: Tue Dec 26, 2023 12:32 pm
Posts: 2
Is it a hard task to get the PDFSharp to work with .NET 8 ahead-of-time (AOT) compiled to native code?

It would be nice to generate PDFs with C# with a high performant self containd application.

I have tried set the project property group <PublishAot>true</PublishAot>
and publish an console application.
It builds and publishes the files for win64 in my case with some trim warnings.
When i creates a new PDFDocument in the code and it throwes the exception:

Unhandled Exception: System.NotImplementedException: Cannot create value for key: /Info
at PdfSharp.Pdf.PdfDictionary.DictionaryElements.GetValue(String, VCF) + 0x34d
at PdfSharp.Pdf.Advanced.PdfTrailer.get_Info() + 0x20
at PdfSharp.Pdf.PdfDocument.get_Info() + 0x20
at PdfSharp.Pdf.PdfDocument..ctor(Stream) + 0x64


Top
 Profile  
Reply with quote  
 Post subject: Re: .NET 8 AOT support
PostPosted: Wed Dec 27, 2023 1:32 pm 
Offline
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 339
Moved the topic.


Cannot reproduce.
See also: http://forum.pdfsharp.net/viewtopic.php?f=2&t=832

_________________
Öhmesh Volta ("() => true")
PDFsharp Team Holiday Substitute


Top
 Profile  
Reply with quote  
 Post subject: Re: .NET 8 AOT support
PostPosted: Sun Dec 31, 2023 4:16 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
toraxe wrote:
Is it a hard task to get the PDFSharp to work with .NET 8 ahead-of-time (AOT) compiled to native code?
I dunno. Didn't try yet.

I think PDFsharp/MigraDoc use reflection to some extent. Creating a size-optimized self-contained package will not work as .NET removes to much code in the process.
Maybe the same problem occurs with AOT. Try a variant that does not remove heuristically unused code if there is one.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
 Post subject: Re: .NET 8 AOT support
PostPosted: Tue Jan 02, 2024 7:10 am 
Offline

Joined: Tue Dec 26, 2023 12:32 pm
Posts: 2
TH-Soft wrote:
toraxe wrote:
Is it a hard task to get the PDFSharp to work with .NET 8 ahead-of-time (AOT) compiled to native code?
I dunno. Didn't try yet.

I think PDFsharp/MigraDoc use reflection to some extent. Creating a size-optimized self-contained package will not work as .NET removes to much code in the process.
Maybe the same problem occurs with AOT. Try a variant that does not remove heuristically unused code if there is one.


Thank you TH-Soft for your reply, I got it working by setting the property <TrimMode>partial</TrimMode>.
As you saied it dident remove as much code but it works.

Thanks!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 116 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group