Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2012 Visual Studio 2012-vshost32-clr2.exe已停止工作_Visual Studio 2012_Bmp_Lockbits_Vshost32 - Fatal编程技术网

Visual studio 2012 Visual Studio 2012-vshost32-clr2.exe已停止工作

Visual studio 2012 Visual Studio 2012-vshost32-clr2.exe已停止工作,visual-studio-2012,bmp,lockbits,vshost32,Visual Studio 2012,Bmp,Lockbits,Vshost32,我正在使用Visual Studio 2012在C#中创建WinForm应用程序,调试时出错: vshost32-clr2.exe has stopped working 我已经搜索过了,但大多数结果都是针对Visual Studio 2010和更低版本的,我得到了类似的解决方案,我认为这些解决方案不适用于Visual Studio 2012: Properties -> Debug -> Enable unmanaged code debugging 资料来源: 其他详细信息:

我正在使用Visual Studio 2012在C#中创建WinForm应用程序,调试时出错:

vshost32-clr2.exe has stopped working
我已经搜索过了,但大多数结果都是针对Visual Studio 2010和更低版本的,我得到了类似的解决方案,我认为这些解决方案不适用于Visual Studio 2012:

Properties -> Debug -> Enable unmanaged code debugging
资料来源:

其他详细信息:

  • 我的项目不使用任何DLL

  • 就我在项目中的进度而言,它仅在宽度为17时发生

我使用以下代码:

        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);
        }
bitmp tmp\u Bitmap=新位图(宽度、高度、系统、绘图、成像、像素格式、格式24bpprgb);
矩形rect=新矩形(0,0,16,tmp_bitmap.Height);
System.Drawing.Imaging.BitmapData bmpData=
tmp_位图.锁位(rect,System.Drawing.Imaging.ImageLockMode.ReadWrite,
tmp_位图。像素格式);
不安全的
{
//获取位图上第一个像素的地址。
字节*ptr=(字节*)bmpData.Scan0;
int bytes=Width*Height*3;//124830[来自190x219 24位位图的总长度]
int b;//单个字节
for(int i=0;i
我认为发布我的代码是必要的,因为只有将该值设置为我的方法时才会发生

我希望你能帮我解决这个问题。
提前非常感谢

不确定这是否是同一个问题,但当我取消选中项目/属性的调试部分下的“启用Visual Studio宿主进程”时,我有一个非常类似的问题得到了解决(消失)。我还启用了本机代码调试。

这个问题可能与将应用程序调试为x64操作系统下的“任何CPU”有关,将目标CPU设置为x86

自从我今天遇到这个问题以来,我增加了2美分

在我的例子中,一个对打印机的调用传递了一些无效的值,它似乎将调试器发送到了睡眠状态


如果您遇到这种情况,请查看是否可以确定电话线路,并确保在呼叫(如打印服务)时没有任何有趣的业务问题。

以下解决方案适合我:

  • 转到项目->属性->调试选项卡
  • 取消选中“启用Visual Studio宿主进程”复选框
  • 选中“启用本机代码调试”选项
  • 希望这有帮助