当我尝试将列表分配给Silverlight中的类时,我遇到了一个错误。我有这门课(为了简单而修剪):
public class ServerStreamingConfiguration : INotifyPropertyChanged
{
private string _DefaultUserID;
[Display(Order = 10, Name = "Default User", GroupName = "Properties", Description = "Default User")]
public string DefaultUserID {
get
{
return _DefaultUserID;
}
set
{
_DefaultUserID = value;
NotifyPropertyChanged("DefaultUserID");
}
}
[Display(Order = 10, Name = "Default User", GroupName = "Properties", Description = "Default User")]
public List<UserForStreaming> DefaultUserIDs { get; set; }
}
我也有这个清单:
private List<UserForStreaming> _UserList;
public List<UserForStreaming> UserList
{
get
{
return _UserList;
}
set
{
_UserList = value;
this.RaisePropertyChanged("UserList");
}
}
事先将UserList填充得很好。它在我的本地环境中工作正常,但是当我将它移动到生产环境时,当我尝试将列表分配给类时会抛出异常。
csc.GetServerStreamConfigsCompleted +=
delegate(object sender, GetServerStreamConfigsCompletedEventArgs e)
{
foreach (ServerStreamingConfiguration ssc in SelectedServer.ServerStreamingProperties)
{
ssc.DefaultUserIDs = UserList;
//error gets thrown above
}
};
我得到一个'对象引用未设置为对象的实例。'错误,但它在本地工作正常!对于如何在生产环境中不起作用,这有点令人难以置信。