Activator.CreateInstance() problem

Results 1 to 2 of 2

Thread: Activator.CreateInstance() problem

  1. #1
    Join Date
    Dec 1969

    Default Activator.CreateInstance() problem

    Hi. I&#039;m trying to dynamically create an instance of an object using Activator.CreateInstance( Type ). The trouble is that the type of object I&#039;m trying to create is a custom type (defined in my own namespace/.dll and not in the .net framework), and Type.GetType() is not finding it, so can&#039;t pass the type to Activator.CreateInstance(). Any ideas? (See code below)<BR><BR>Thanks,<BR>Corey<BR><BR>// code<BR><BR>System.Type objType = System.Type.GetType("Aries.Textbox");<BR>Aries.Tex tbox objTextbox = <BR> (Aries.Textbox)System.Activator.CreateInstance( objType );<BR><BR>// /code<BR><BR>The error I&#039;m getting is on the second line:<BR>"Value cannot be null. Parameter name: type"

  2. #2

    Default RE: Activator.CreateInstance() problem

    Look closer at GetType(string).<BR>You need to specify the assembly name if it is not loaded in the executing assembly<BR><BR>"Aries.Textbox, whatAssembly"<BR>I hope that the cast you have there is only for testing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts