Click here to Skip to main content
16,022,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a asp application where I open an excel document with closedXML. Everything works as it should in Visual Studio; however, when I publish this to my production server I get an error. Am I missing fonts on the server?

The stack trace is:

The type initializer for 'SixLabors.Fonts.Tables.TableLoader' threw an exception.

at SixLabors.Fonts.FontCollection.AddImpl(Stream stream, CultureInfo culture, FontDescription& description) at ClosedXML.Graphics.DefaultGraphicEngine.AddEmbeddedFont(FontCollection fontCollection) at ClosedXML.Graphics.DefaultGraphicEngine..ctor(String fallbackFont) at ClosedXML.Graphics.DefaultGraphicEngine.<>c.<.cctor>b__31_0() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at ClosedXML.Excel.XLWorkbook..ctor(LoadOptions loadOptions) at ClosedXML.Excel.XLWorkbook..ctor(String file, LoadOptions loadOptions) at UMCT.rollUpTheData.btnSaveExcel_Click(Object sender, EventArgs e)


What I have tried:

I am using .net framework 4.6.1 and have tried to update all the packages.
Posted

After Googling "The type initializer for 'SixLabors.Fonts.Tables.TableLoader' threw an exception", are the fonts installed on the production server?
 
Share this answer
 
Comments
whistle1973 4-Jun-24 14:25pm    
Yes… I have confirmed that the fonts I am using in the spreadsheet are installed. It looks like ClosedXML uses “Microsoft Sans Serif”

I have made sure the fonts used in the excel files are installed. I may be missing something.

Thanks for your help.
Dave Kreskowiak 4-Jun-24 16:57pm    
How about the 'SixLabors.Fonts' it's actually mentioning?
Richard Deeming 5-Jun-24 3:30am    
If you had to install the fonts on the server, have you restarted the server since you installed them? ASP.NET code won't be able to use the newly-installed fonts until you do...
At a guess, I would say that the fonts aren't present at the location you think they are. While you might have them on the server, if the path isn't 100% correct in terms of a deployed web application, it won't see the files.
 
Share this answer
 
Thank you all so much for the help. I was able to get the problem resolved. I made two changes. The first was installing fonts on the server. I am not sure this was what solved the problem. The second was installing the ClosedXML.Signed NetGet package instead of the ClosedXML package. I found a suggestion on a forum. After doing this everything seemed to fall into place.

Again thank you all for your help!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900