我使用Visual Studio 2012创建C#中的WinForm应用程序,我得到一个错误,当我调试它:的Visual Studio 2012 - vshost32-clr2.exe已停止工作
vshost32-clr2.exe has stopped working
我已经搜查但多数结果为Visual Studio 2010和更低的,我也得到类似的解决方案,我认为这是不适用的Visual Studio 2012:
Properties -> Debug -> Enable unmanaged code debugging
来源:vshost32.exe crash when calling unmanaged DLL
个其他细节:
我的项目不使用任何DLL。
只要我在我的项目进展,它只发生在宽度为。
我使用下面的代码:
Bitmap tmp_bitmap = new Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Rectangle rect = new Rectangle(0, 0, 16, tmp_bitmap.Height);
System.Drawing.Imaging.BitmapData bmpData =
tmp_bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
tmp_bitmap.PixelFormat);
unsafe
{
// Get address of first pixel on bitmap.
byte* ptr = (byte*)bmpData.Scan0;
int bytes = Width * Height * 3; //124830 [Total Length from 190x219 24 Bit Bitmap]
int b; // Individual Byte
for (int i = 0; i < bytes; i++)
{
_ms.Position = EndOffset - i; // Change the fs' Position
b = _ms.ReadByte(); // Reads one byte from its position
*ptr = Convert.ToByte(b);
ptr++;
// fix width is odd bug.
if (Width % 4 != 0)
if ((i + 1) % (Width * 3) == 0 && (i + 1) * 3 % Width < Width - 1)
{
ptr += 2;
}
}
// Unlock the bits.
tmp_bitmap.UnlockBits(bmpData);
}
我想张贴我的代码是必要的,因为它只有在这样的值设置为我的方法进行。
我希望你能帮我解决这个问题。 非常感谢您提前!