System.ArgumentException: 'Font '?' cannot be found.'

Daedalus_28 0 Reputation points
2023-02-11T12:51:51.3866667+00:00

I get following exception running a REST API server (.Net Framework 4.8) in IISExpress on my computer. Starting it from my Visual Studio 2019.

System.ArgumentException: 'Font '?' cannot be found.'

When I run a small Windows Form application calling SystemFonts.CaptionFont and DefaultFont, all work fine.

I'm running Windows 10 Pro 19045.2486, will all updates installed.

Call stack:

at System.Drawing.FontFamily.GetGdipGenericSansSerif()

at System.Drawing.FontFamily.CreateFontFamily(String name, FontCollection fontCollection)

at System.Drawing.FontFamily…ctor(String name, Boolean createDefaultOnFail)

at System.Drawing.Font.Initialize(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)

at System.Drawing.Font…ctor(String familyName, Single emSize, FontStyle style, GraphicsUnit unit)

...

I have tried following:

  • I have set full rights in Fonts and all below to my local user, even everyone and administrator.
  • I have deactivate and uninstall MS defender and my anti virus software - rebooted computer.
  • I have done a iisreset.
  • The micross.ttf is present in C:\Windows\Fonts.
  • ttf are allowed in IIS Express.

Any suggestions what I could do next to fix this issue?

Windows for business Windows Client for IT Pros User experience Other
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,746 Reputation points
    2023-02-13T17:10:30.6233333+00:00

    Hello there,

    While troubleshooting performance issues, the best way fault isolation technique is capturing [APIM inspector trace that shows time taken in each section (Inbound / Backend / Outbound).

    The error message "Font '?' cannot be found." can be caused by an incorrect font name. The '?' is hard-coded into the SafeNativeMethods.Gdip.StatusException method. When the GetGdipGenericSansSerif calls the underlying GDI+ function GdipGetGenericFontFamilySansSerif and it returns error status 14, you saw the exception.

    The below thread discusses the same issue and you can try out some troubleshooting steps from this and see if that helps you to sort the Issue.

    https://social.msdn.microsoft.com/Forums/en-US/36ab500f-4d38-418f-97f5-dfece24c281f/quotsystemargumentexception-font-cannot-be-foundquot-during-application-start-up-any?forum=winforms

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer–

    0 comments No comments

  2. Limitless Technology 44,746 Reputation points
    2023-02-13T17:10:43.3833333+00:00

    Double post

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.