title: Get instance of class dynamically in .NetCore
body: <p>I need class instance from string to check if it has certain Attribute.
  I have tried it like this</p>
  
  <pre><code>Type type = Assembly.GetEntryAssembly().GetType("ClassName");
  object entity = Activator.CreateInstance(type);
  var tableAttribute = entity.GetType().GetTypeInfo().GetCustomAttribute&lt;TableAttribute&gt;(); 
  </code></pre>
  
  <p>but type is null ?</p>
  
  <p>Entire code in TestConsoleApp:</p>
  
  <pre><code>using System;
  using System.ComponentModel;
  using System.Reflection;
  
  namespace AssemblyTest
  {
      [Description("TestDescription")]
      public class TestClass { }
      //
      public class Program
      {
          public static void Main(string[] args)
          {
              Type type = Assembly.GetEntryAssembly().GetType("TestClass");
  
              if(type == null)
                  Console.WriteLine("Object type is NULL.");
              else
                  Console.WriteLine("Object type has value.");
  
              object entity = Activator.CreateInstance(type);
  
              var tableAttribute = entity.GetType().GetTypeInfo().GetCustomAttribute&lt;DescriptionAttribute&gt;();
          }
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/60b5D.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/60b5D.jpg" alt="enter image description here"></a></p>