Type.GetType(String)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter

    #1

    Type.GetType(String)

    Hi, the following is my question defined as below:
    - C# language
    - a custom dll,the class name = theNS.theClass
    - in a testing project, after add the reference
    - code: Type theType = Type.GetType("t heNS.theClass") ;
    - problem : theType is set to null.
    Please advice. Thanks.
    Peter
  • Mattias Sjögren

    #2
    Re: Type.GetType(St ring)

    Peter,
    [color=blue]
    >Hi, the following is my question defined as below:
    >- C# language
    >- a custom dll,the class name = theNS.theClass
    >- in a testing project, after add the reference[/color]
    [color=blue]
    >- code: Type theType = Type.GetType("t heNS.theClass") ;
    >- problem : theType is set to null.[/color]

    Type.GetType only search Mscorlib.dll and the calling assembly when
    you specify only a type name. The solution is to specify the full type
    and assembly name, such as

    Type.GetType("t heNS.theClass, YourAssembly");

    But if you have a reference to that assembly, it's even better to use
    the typeof operator.

    typeof(theNS.th eClass),



    Mattias

    --
    Mattias Sjögren [MVP] mattias @ mvps.org

    Please reply only to the newsgroup.

    Comment

    Working...