2013-05-13 121 views
3

我使用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); 
     } 

我想张贴我的代码是必要的,因为它只有在这样的值设置为我的方法进行。

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

回答

2

不确定这是否是同一个问题,但我有一个非常类似的问题,当我在Project/Properties的Debug部分下取消选中“启用Visual Studio宿主进程”时解决(消失)了。我也启用了本地代码调试。

1

这个问题可以调试应用程序,“任何CPU”在x64操作系统,设置目标CPU为86

0

添加我的2美分,因为我碰到了今天这个有关。

在我的情况下,打印机的调用传递了一些无效的值,并且它似乎发送调试器与鱼一起睡觉。

如果遇到这一点,看看你能不能找出行,并确保周围有一个电话出去不好笑业务问题(如打印服务)

0

以下解决方案为我:

  1. 转到项目 - >属性 - >调试选项卡
  2. 未选中“启用在Visual Studio宿主进程”复选框
  3. 经过“启用原生代码调试”选项

希望这会有所帮助。

相关问题