0
我有一個C#項目,其中使用了託管C++類。 這個託管的C++類包裝了一個非託管的C++代碼。在VS 2010中調試時未調用析構函數
我有這樣的代碼塊;
if (true)
{
ManagedFoo foo = new ManagedFoo();
}
//GC.Collect(); // I also tried with this one but result is same
我已經把一個簡單的輸出串類的析構函數。
如果我從Visual Studio運行程序,foo的析構函數不會被調用。 但是,如果我通過雙擊它(它是一個控制檯應用程序)運行程序,立即調用 析構函數。
爲什麼它的行爲如此呢?
非常感謝, 問候
重複從http://stackoverflow.com/questions/755680/gc-collect-doesnt-seem-to-work-in-debug-mode ? – nob 2010-08-26 08:25:36