1

I'm facing an issue to produce an excel file in local machine through a SQL Server job using ClosedXML in a script task (C#). The job under a service account and it has admin privilege in local machine. Below is the error it is producing.

"Unable to find font Tahoma or fallback font Microsoft Sans Serif. Install missing fonts or specify a different fallback font through 'LoadOptions.DefaultGraphicEngine = new DefaultGraphicEngine("Fallback font name")'.".

I've checked the fonts (Tahoma and Microsoft Sans Serif) exists in the C:\Windows\Font (Based on the font location mentioned in https://github.com/SixLabors/Fonts/blob/main/src/SixLabors.Fonts/SystemFontCollection.cs#L27)

However, when I run the same code in Visual Studio it can successfully produce Excel file without complaining about anything.

My assumption is that it is not permission related as I can produce the Excel files under my account through visual studio but not from SQL Server.

Note: All the activity to produce the Excel file is happening locally (no remote call). Any help or suggestion is appreciated.

Add the LoadOptions.DefaultGraphicEngine = new DefaultGraphicEngine("Fallback font name") in the code. I have selected <fallback font name> that exists in the below directories: @"%SYSTEMROOT%\Fonts",@"%APPDATA%\Microsoft\Windows\Fonts",@"%LOCALAPPDATA%\Microsoft\Windows\Fonts".

Copy the Tahoma and Microsoft Sans Serif in those folders.

Checked any deny permission exists for the service account and my account.

Run the job both Service account and my account from SQL Server.

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • So is this a CmdExec SQL Agent job step? Does the process work if you run it from a command prompt using `RUNAS /noprofile ...`? That's effectively what CmdExec job steps do and the absence of a profile also means the absence of registry hives which breaks a lot of software. – AlwaysLearning Dec 09 '22 at 23:12
  • This is a SSIS job, scheduled to run under a service account in SQL server agent service. – Istiaque Hassan Dec 10 '22 at 00:10
  • If, inside the running SSIS job, you enumerate the contents of `SixLabors.Fonts.SystemFonts.Collection.SearchDirectories` is it an empty collection or has it successfully used environment variables to resolve `%SYSTEMROOT%\Fonts` to `C:\Windows\Fonts`, etc.? – AlwaysLearning Dec 10 '22 at 01:07

0 Answers0