Thread: Type.GetType() returns null

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    80

    Type.GetType() returns null

    I'm using Type.GetType(string) to extract the type from a string. The string contains the fully qualified name of a type. In my case it is:

    String typeName = "ToolShed.Tools.NotifyService";
    Type.GetType(typeName);

    I tried the exception throwing version of GetType, and it said that it threw because it couldn't find the type in the current assembly. However, since I have fully qualified the type name WITH an assembly, shouldn't it look there?

    Thanks for any advice,
    Andrew

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    You did not qualify an assembly, you just gave the namespace of your type. It may still reside in another assembly ( file ).

    Maybe you can describe what you plan to do with the call so we can suggest another method. Dynamically loading something doesn't really make sense; if you know the name beforehand you can as well link the assembly as a reference like normal, I guess.

    If you want to load another assembly at runtime, have a look into the Assembly class.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    80
    Sorry, yeah. I was a bit confused and I didn't explain my intentions very well:

    The assembly that the type lives in IS loaded when the program is run. The user will be able to input a string that represents a type (I will then Activate an instance of this type using the remoting framework). So, I have a string which contains the type name, and I need to obtain it's Type from that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help Debugging my AVL tree program.
    By Nextstopearth in forum C Programming
    Replies: 2
    Last Post: 04-04-2009, 01:48 AM
  2. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  3. Help with yacc/compiler design/seg fault
    By trippeer in forum C Programming
    Replies: 1
    Last Post: 04-08-2005, 03:43 AM
  4. Problem with a menu.
    By Rare177 in forum Windows Programming
    Replies: 4
    Last Post: 09-07-2004, 11:51 PM
  5. button 'message'
    By psychopath in forum Windows Programming
    Replies: 12
    Last Post: 04-18-2004, 09:57 AM