我創建了一個帶有控件的dll。當我瀏覽dll時,它將控件成功添加到工具箱中。問題是,當我運行的應用程序時,我收到以下錯誤: An unhandled exception of type 'System.StackOverflowException' occurred in xxx.dll
類型'System.StackOverflowException'未處理的異常
在調試器去突出錯誤是在下面的函數的方法:
public ItemType this[int i]
{
get
{
return (ItemType)this[i];
}
set
{
this[i] = value;
}
}
,因爲我知道發生此錯誤由於遞歸調用,我如何重寫上述或修改它來克服這個問題。請儘快提供任何代碼幫助
謝謝
現在我得到的回報_list不設置到對象的實例的對象引用[I]; – user1885308
只需首先初始化列表。當然,在示例代碼中_list始終爲空。 – Tobias
其實itemtype是BaseItemCollection ._ knownTypes = new Type [] {typeof(ItemType)};那麼我應該如何改變遞歸函數 –
user1885308