Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7085361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:24:55+00:00 2026-05-28T07:24:55+00:00

I am instantiating my objects with the classical object myObject = Activator.CreateInstance(myType); code and

  • 0

I am instantiating my objects with the classical

object myObject = Activator.CreateInstance(myType);

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 NullReferenceException exception :

Object reference not set to an instance of an object.

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 ?

EDIT : here’s the code of the problem

//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);

The last line fails and the error is a NullReferenceException with the details :

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& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
[...]

I call c/c the 30/40 other error lines but I don’t think it is that usefull…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:24:55+00:00Added an answer on May 28, 2026 at 7:24 am

    When you say your constructor references another object, do you mean you should be passing it to the constructor as a parameter? If so, then there is an overload for Activator.CreateInstance that allows you to specify the parameter values. See MSDN for details, but basically, you add them after the type.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am instantiating a .NET COM object and would like to update the ConfigurationManager.AppSettings
We have a classic ASP page that is instantiating a .Net object through a
I have code using JPA and everything works fine in my development environment and
I'm just now getting into instantiating JavaScript object literals using a prototype constructor, but
I want to use objects(java style) in my PHP code after by instantiating objects
I am instantiating various objects based on an xml file. To create an object
I am working with Active Directory using C#. Instantiating the PrincipalContext object seems to
As you can see below, in the constructor I'm instantiating a validation object so
I am successfully instantiating/automating Visual Studio using the following code: System.Type t = System.Type.GetTypeFromProgID(VisualStudio.DTE.9.0);
Why instantiating objects of same class within its constructor throws StackOverflowError ? For instance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.