>After more thinking about this, I think it is normal we are not allowed to assigned a NameObjectCollectionBase object to another one as its main root would differ at first making sense for the error message I am getting at the designer level. It might work for a dictionary but not for a NameObjectCollectionBase object.
>
>I will have to try with the locking mechanism instead.
>
>In the meantime, if you see a workaround with the 2nd approach or if you would know why I am getting this, feel free to let me know.
NameObjectCollectionBase or dictionary - the class is does not matter
I've used the volatile keyword
http://msdn.microsoft.com/en-us/library/x13ttww7.aspxSee also here
http://www.yoda.arachsys.com/csharp/threads/volatility.shtml public class AClass
{
private volatile Dictionary<string, string> Tables_;
public Dictionary<string, string> Tables
{
get; private set;
}
public AClass()
{
Tables_ = new Dictionary<string, string>();
Tables_.Add("1", "one");
Tables_.Add("2", "two");
}
public void ReInitializeTables()
{
Dictionary<string, string> tmp = new Dictionary<string, string>();
tmp.Add("3", "three");
tmp.Add("4", "four");
Tables_ = tmp; // assign new initialized object
}
}
Gregory