【问题标题】:Visual Studio 2012 - vshost32-clr2.exe has stopped workingVisual Studio 2012 - vshost32-clr2.exe 已停止工作
【发布时间】:2013-05-13 13:14:36
【问题描述】:

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

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。

  • 就我的项目进展而言,它仅在宽度为 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);
        }

我认为发布我的代码是必要的,因为它只在我的方法设置了这样的值时才会发生。

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

【问题讨论】:

    标签: visual-studio-2012 bmp lockbits vshost32


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        自从我今天遇到这个问题以来,加上我的 2 美分。

        在我的例子中,对打印机的调用传递了一些无效值,似乎它使调试器与鱼一起进入睡眠状态。

        如果您遇到这种情况,请查看是否可以查明线路并确保呼叫周围没有有趣的业务问题(例如打印服务)

        【讨论】:

          【解决方案4】:

          以下解决方案对我有用:

          1. 转到项目->属性->调试选项卡
          2. 取消选中“启用 Visual Studio 托管进程”复选框
          3. 选中“启用本机代码调试”选项

          希望这会有所帮助。

          【讨论】:

            猜你喜欢
            • 2011-10-18
            • 2014-06-11
            • 1970-01-01
            • 2012-03-31
            • 2012-10-12
            • 2016-07-09
            • 2016-03-08
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多