这段代码在应用程序关闭之前运行良好,只有在应用程序控件上设置字体时才会出现故障。在所有其他我尝试过的使用.NET CF 3.5的Motorola、Intermec、Psion、HHC设备上都可以正常运行。
这是我目前的测试代码:
[MTAThread]
static void Main()
{
Control oCtrl = new Control();
oCtrl.Font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
// Setting the controls font to null works
// oCtrl.Font = null; Works
// Setting the Control to null does not work, still get error
// oCtrl = null; Doesn't work
// Setting a font, not on a control, also works fine.
// System.Drawing.Font font = new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold);
}
我看到了一些似乎相关的链接:
但是到目前为止,我只发现消除应用程序中的字体是唯一的建议。在这种情况下,有太多地方设置了字体,包括链接的程序集,所以不可能实现。
还有其他人见过这样的情况吗?似乎与控件没有正确处理这些版本的字体有关。