2011-02-22 12 views

回答

0

警告是serviceLocator爲空?

沒有看到任何更多的代碼的(以得到一個什麼樣的其他合同可能會在劇本的想法),你可以把

Contract.Assume(serviceLocator != null); 

上線的上方。

0

也許serviceLocator.GetInstance<Shell>()如果找不到實例則返回null。

嘗試爲該情況提供替代控制流程。

var instance = serviceLocator.GetInstance<Shell>(); 
if (instance == null) 
    throw new InvalidOperationException("Shell instance is missing."); 
HtmlPage.RegisterScriptableObject("Shell", instance); 
相關問題