2013-05-13 120 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. 經過「啓用原生代碼調試」選項

希望這會有所幫助。

相關問題