Activator.CreateInstance needs another object to be instantiated
<p>I am instantiating my objects with the classical</p>

<pre><code>object myObject = Activator.CreateInstance(myType);
</code></pre>

<p>code and if works fine.
The thing is that, now, Id like to instantiate an object and in its constructor, there is a reference to another object.
So if I just do the code above, I got a <code>NullReferenceException</code> exception :</p>

<pre><code>Object reference not set to an instance of an object.
</code></pre>

<p>I tried to instantiate the concerned object (with Activator.CreateInstance) but I got the same exception...
I feel like instantiating the problematic object before my 2nd CreateInstance call is not enough. What should I do ?</p>

<p>EDIT : here's the code of the problem</p>

<pre><code>//A regionManager in needed by MainView as far as I understand the Exception's details
var regionManager = Assembly.LoadFrom("RegionView.dll");
Type rmType = regionManager.GetType("Framework.Hmi.RegionManager");
object obj = Activator.CreateInstance(rmType);
//This works !

var shellViewLibrary = Assembly.LoadFrom("ShellView.dll");
Type svType = shellViewLibrary.GetType("Framework.ShellView.MainView");
object objjj = Activator.CreateInstance(svType);
</code></pre>

<p>The last line fails and the error is a <code>NullReferenceException</code> with the details :</p>

<pre><code>at Hmi.RegionManager.get_RegionFactory()
at Hmi.RegionManager.CreateRegion(DependencyObject element)
at Hmi.RegionManager.OnSetRegionNameCallback(DependencyObject element, DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry&amp; newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
[...]
</code></pre>

<p>I call c/c the 30/40 other error lines but I don't think it is that usefull...</p>
