2011-09-22 53 views
4

當我調試我的ASP.NET應用程序並在中斷點執行中斷時,我無法使用Debug Watches讀取type變量。爲什麼?我得到錯誤VS調試器不能按預期工作

type The name 'type' does not exist in the current context 

的代碼工作正常,只是在調試的問題,我看不懂,同時調試所有變量。

var converterSubClasses = new List<Type>(); 
GetClassHierarhy(ref converterSubClasses, converterClass); 

foreach (var type in converterSubClasses) 
{ 
    /* break point here */ var classProperties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); 
    /* skip code */ 
} 

enter image description here

+0

你可以將鼠標移到單詞類型上並以此方式查看該值嗎? –

+0

@JesusRamos當我在其他變量上移動時,我在類型單詞上移動時沒有得到任何彈出消息。 – Tomas

+1

你可以添加屏幕截圖嗎? – Reniuz

回答

2

你調試在Release模式編譯的代碼?根據優化,編譯器使用變量type可能實際上並不存在。確認你正在調試Debug編譯的代碼,然後嘗試。 (我的循環沒有意義,當試圖在發佈模式下進行調試時,整個部分都會跳躍)。

+0

我可以確認我正在以調試模式進行調試。 – Tomas

+0

您是否正在針對IIS進行調試或者您是否在本地進行調試?如果您正在針對IIS進行調試,則可能需要重新部署新編譯的調試代碼。 – Joshua