title: Exception with invoking static method in Abstract Class Using Reflection
body: <p>Unable to solve this issue and desperately need help. My project is calling a dll with below class. I need to use the static method using reflection but unable to make it work due to an exception "Object reference not set to an instance of an object"</p>
  
  <pre><code>namespace Binit.Core.Database
  {
  
  public abstract class DbFormat
  {
      protected static DbFormat m_internalDbFormat;
      public static DbFormat Create()
       {
            return m_internalDbFormat.internalCreate();
       }
  }
  }
  </code></pre>
  
  <p>Below code works</p>
  
  <pre><code>Binit.Core.Database.DbFormat format;
  format = Binit.Core.Database.DbFormat.Create();
  </code></pre>
  
  <p>Below code using reflection fails</p>
  
  <pre><code>Assembly CoreDatabaseAssembly = Assembly.LoadFrom(Path.Combine(APath, @"Binit.Core.Database.dll"));
  Type typDbFormatClass = CoreDatabaseAssembly.GetType("Binit.Core.Database.DbFormat");
  MethodInfo createFormatMethod = typDbFormatClass.GetMethod("Create", BindingFlags.Static | BindingFlags.Public, null, new Type[] { }, null);
  object objDbFormat = createFormatMethod.Invoke(null, null);
  </code></pre>
  
  <p>Exception:</p>
  
  <p>Inner Exception Shows <code>Object reference not set to an instance of an object.</code></p>
  
  <p>InnerException null</p>
  
  <p>Stacktrace</p>
  
  <pre><code>at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]   arguments, Signature sig, Boolean constructor)
  at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
  at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
  at AB.INIT.stringToValue(String valueInUnits, String dimension, String sourceUnit, String destinationUnit)
  </code></pre>
  
  <p>m_internalDbFormat is null when i am using reflection . But when i do direct reference code it doesn't become null even though i am executing only create method. I believe it means the references are loaded using direct reference and using reflection i may need to set them explicity. it seems Binit.Core.Database.Implementation is the dll that is referenced in the project doing direct reference. so i might need to invoke this explicity . Any ideas. </p>