我使用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);
}
我想張貼我的代碼是必要的,因爲它只有在這樣的值設置爲我的方法進行。
我希望你能幫我解決這個問題。 非常感謝您提前!