如何傳遞空值的方法傳遞空值的方法
[Import("Default", typeof(ISomeInterface), AllowRecomposition = true, AllowDefault = true)]
public ISomeInterface x { get; set; }
// x is null till now
void DoWork(ISomeInterface obj) //Not working
{
if (obj == null)
{
//Download and Satisfy
DeploymentCatalog DC = new DeploymentCatalog("TheXAPfile.xap");
DC.DownloadCompleted += (s, e) =>
{
catalog.Catalogs.Add(f); //catalog is AggregateCatalog
obj.Show();
};
DC.DownloadAsync();
}
else
{
obj.Show();
}
}
由於
什麼是不工作?你有一個實現'ISomeInterface'的值類型嗎? – dlev
顯示發生實際錯誤的代碼部分以及它給出的消息(如果有),或者在編譯器錯誤時顯示編譯器消息。 –
System.NullReferenceExcption:[Arg_NullRefrenceException] – MrBassam