Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Type.GetType(name)

Type.GetType(name)

Scheduled Pinned Locked Moved C#
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cobyjone
    wrote on last edited by
    #1

    I am working on a windows app and having some trouble getting type information by just the name. I have to load a file that will have several different type names (Type.FullName). When I call Type.GetType(fullname), it is always returning null, even for types that I would assume it wouldn't like System.Windows.Forms.TextBox. The only way that I can get it to return a type is if it is a local assembly, put it in format of 'Fullname,AssemblyName'. If it is not a local assembly, then I have to put it in the format of 'AssemblyQualifiedName'. This is ok, but it kinda screws some of the useability of the app. Does any one know a way around this? I know that I can use just the full name of the type if I am doing straight from the assembly reference (Assembly.GetType(fullname)), but I would prefer it if I didn't have to have a reference to the assembly to get the type (even though the assembly will be loaded at this point anyways). Any ideas would be greatly appreciated?

    T 1 Reply Last reply
    0
    • C cobyjone

      I am working on a windows app and having some trouble getting type information by just the name. I have to load a file that will have several different type names (Type.FullName). When I call Type.GetType(fullname), it is always returning null, even for types that I would assume it wouldn't like System.Windows.Forms.TextBox. The only way that I can get it to return a type is if it is a local assembly, put it in format of 'Fullname,AssemblyName'. If it is not a local assembly, then I have to put it in the format of 'AssemblyQualifiedName'. This is ok, but it kinda screws some of the useability of the app. Does any one know a way around this? I know that I can use just the full name of the type if I am doing straight from the assembly reference (Assembly.GetType(fullname)), but I would prefer it if I didn't have to have a reference to the assembly to get the type (even though the assembly will be loaded at this point anyways). Any ideas would be greatly appreciated?

      T Offline
      T Offline
      Tom Larsen
      wrote on last edited by
      #2

      Can I ask what you are attempting to do? Type information is somewhat non-human friendly just because it is designed to be that way. :-) Why are you asking the user for a type which may or may not be in any loaded assembly? Maybe you should instead offer a list of loaded types with a filter?

      C 1 Reply Last reply
      0
      • T Tom Larsen

        Can I ask what you are attempting to do? Type information is somewhat non-human friendly just because it is designed to be that way. :-) Why are you asking the user for a type which may or may not be in any loaded assembly? Maybe you should instead offer a list of loaded types with a filter?

        C Offline
        C Offline
        cobyjone
        wrote on last edited by
        #3

        nevermind, i just altered the file format to allow the assembly name as well.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups