System.Drawing in Windows or ASP.NET services

后端 未结 5 1057
遥遥无期
遥遥无期 2020-11-28 10:05

According to MSDN, it is not a particularly good idea to use classes within the System.Drawing namespace in a Windows Service or ASP.NET Service. Now I am d

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-28 10:52

    You could use TextRenderer instead. I know it's weird to use something from System.Windows.Forms in ASP.NET, but it doesn't appear to have the same warning about not being supported in ASP.NET. I have used both TextRenderer and Graphics.MeasureString to measure strings in ASP.NET applications, so they both work. I had never seen the warning about System.Drawing not being advisable in ASP.NET.

    TextRenderer is a lot slower than Graphics.MeasureString, FWIW.

提交回复
热议问题