PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Oct 13, 2024 11:29 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun May 07, 2023 8:35 am 
Offline

Joined: Fri May 05, 2023 2:19 pm
Posts: 1
When using MigraDoc in a background job server (I use Hangfire), we have situations where setting the GlobalFontSettings.FontResolver property can occur several times leading to an exception. Even when using a mutex the setting code can still run. If the GlobalFontSettings is implemented as an instance class which is passed to the document renderer the problem will disappear.
In .NET Core and up it would in any case be better to refactor the code to be able to use the DI container via a IServiceProvider instance.


Top
 Profile  
Reply with quote  
PostPosted: Mon May 08, 2023 8:37 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 995
Location: CCAA
Arolla wrote:
When using MigraDoc in a background job server (I use Hangfire), we have situations where setting the GlobalFontSettings.FontResolver property can occur several times leading to an exception.
There is no exception when you set the same FontResolver multiple times. Make sure the FontResolver is a singleton and a mutex is used to create that singleton. Been there, done that.

As of now, it is by design that there is a single, global font resolver.

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


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group