0

我有以下代码:

public class BufferedChart
{
  ...
  private static LineClass m_lineDrawingAlgorithm = new LineClass();
  ...

  public BitmapData LockBitmap()
  {
    ...
    unsafe
    {
      // Clear bitmap data (clear bitmap)
      m_lineDrawingAlgorithm.ClearBitmapData(ref (*((int*)bmData.Scan0.ToPointer())), m_bufferBitmap.Width * m_bufferBitmap.Height);
      m_cleared = true;
    }
    ...
  }
}

并且在访问 lineDrawingAlgorithm 时出现 NullReferenceException 失败。它不是 100% 可重现的,但这个参考怎么可能是空的?它与unsafe块有关还是与 LineClass 是 COM 对象的事实有关?

4

0 回答 0