I'm trying to get a Type object from type full name i'm doing the folowing:
Assembly asm = Assembly.GetEntryAssembly();
string toNativeTypeName="any type full name";
Type t = asm.GetType(toNativeTypeName);
I get null, why?
the assembly is my executable (.net executable) and the type name is: System.Xml.XmlNode
The origin of C is closely tied to the development of the Unix operating system, originally implemented in assembly language on a PDP-7 by Dennis Ritchie and Ken Thompson, incorporating several ideas from colleagues. Eventually, they decided to port the operating system to a PDP-11.
Program consists of set of instructions written in a High-level language like English. The computer only understands Low-level language. We need a translator to convert high-level language to low-level language and vice versa. We have two translators known as compiler and interpreter.
C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners.
Well, if that really is the type's full name (i.e. including namespace) and it's in that assembly, then it should work. Could you give an example where it doesn't? As you're using Assembly.GetType
rather than Type.GetType
you shouldn't include the assembly name in the type name.
Note that the name for a generic type isn't what you might expect it to be. For instance, you'd use:
assembly.GetType("System.Collections.Generic.List`1");
to get the generic list type, then use Type.MakeGenericType
to provide type arguments.
Of course, that's only relevant when the type is generic. If that's not the problem, I'd double check that the type really is in your entry assembly.
EDIT: Oh, and be aware that nested types will be "Container+Nested" rather than "Container.Nested" if that's relevant...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With