Skip to content
标签
欢迎扫码关注公众号

C# 创建 System.Drawing.Font 时报错

本机(win7)调试 .NET 项目时,有时候会出现如下错误(错误信息来自系统事件日志):

txt
错误应用程序名称:w3wp.exe,版本:7.5.7601.17514,时间戳:0x4ce7afa2
错误模块名称:gdiplus.dll,版本:6.1.7601.24234,时间戳:0x5b71a963
异常代码:0xc0000005
错误偏移量:0x000000000015285d
错误进程 ID: 0x2da00
错误应用程序启动时间:0x01d498cee277d2ee
错误应用程序路径:c:\windows\system32\inetsrv\w3wp.exe
错误模块路径:C:\Windows\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.24234_none_1458b3828b92cc5f\gdiplus.dll
报告 ID: 23a9004e-04c2-11e9-a9bc-408d5c5e7924

关于 gdiplus.dll,按照 百度百科 上的说法:

gdiplus.dll 是 GDI 图形设备接口图形界面相关模块。

这段代码的功能就是生成验证码的图片。Debug 发现是这句代码报的错:

csharp
new System.Drawing.Font(Fonts[findex], fSize, System.Drawing.FontStyle.Bold);

字体用的是 ArialGeorgia,系统默认的字体,也再次确认过了本机是有的。

现象是有时候一直出错,但中间偶尔会正常一次。现在就又一直都是好的,啥代码都没改就好了。完全猜不透是哪里的问题。

Page Layout Max Width

Adjust the exact value of the page width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the page layout
A ranged slider for user to choose and customize their desired width of the maximum width of the page layout can go.

Content Layout Max Width

Adjust the exact value of the document content width of VitePress layout to adapt to different reading needs and screens.

Adjust the maximum width of the content layout
A ranged slider for user to choose and customize their desired width of the maximum width of the content layout can go.