Lloyd
Sun Jul 24 07:33:10 CDT 2005
I counter your argument with mine! (it's in the attached file).
You use fully qualified name including the assembly, that's a good idea.
However in my previous, unrigorous attempt, I just use type name (name space
+ type name)
(As you suggested, BTW in: Type.GetType("System.Text.StringBuilder"))
And this doesn't work!
tss.. you cheated ;-)
"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1d4d890e12ea61fd98c503@msnews.microsoft.com...
> Lloyd Dupont <ld@NewsAccount.galador.net> wrote:
>> I want to add, on top everyone said, that Type.GetType() is very good
>> at missing type. From what I remember of my test it would only look
>> in the list of currently loaded Assembly. (which could be a small
>> subset of all the Assembly used by your program)
>
> I don't believe so. Try this:
>
> using System;
>
> public class Test
> {
> static void Main()
> {
> Console.WriteLine (Type.GetType("System.Data.DataTable, "+
> "System.Data, "+
> "Version=2.0.0.0, "+
> "Culture=neutral, "+
> "PublicKeyToken=b77a5c561934e089"));
> }
> }
>
> System.Data isn't going to be loaded before Main is called, but using
> Type.GetType makes the assembly get loaded.
>
> It also works with user-defined libraries. For instance:
>
> Lib.cs:
> public class LibraryClass
> {
> }
>
> Compile with: csc /target:library out:Library.dll Lib.cs
>
> Test.cs:
> using System;
>
> public class Test
> {
> static void Main()
> {
> Console.WriteLine (Type.GetType("LibraryClass, Library"));
> }
> }
>
> Compile with: csc Test.cs
> (Note the lack of reference to Library.dll)
>
> It loads the assembly and the type just fine.
>
> --
> Jon Skeet - <skeet@pobox.com>
>
http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
begin 666 TL.cs
M=7-I;F<@4WES=&5M.PT*#0HO+R!C<V,@+VYO;&]G;R O;W5T.E1,+F5X92!4
M3"YC<R @)B8@5$P-"G!U8FQI8R!C;&%S<R!497-T#0I[#0H)<W1A=&EC('9O
M:60@36%I;B@I#0H)>PT*"0E*;VAN*"D[#0H)"4QL;WED*"D[#0H)?0T*#0H)
M<W1A=&EC('9O:60@3&QO>60H*0T*"7L-"@D)0V]N<V]L92Y7<FET94QI;F4H
M(DUY4V5L9CH@(B K(%1Y<&4N1V5T5'EP92@B5&5S="(I*3L-"@D)0V]N<V]L
M92Y7<FET94QI;F4H(D1A=&%486)L93H@(B K(%1Y<&4N1V5T5'EP92@B4WES
M=&5M+D1A=&$N1&%T851A8FQE(BDI.PT*"7T-"@T*"7-T871I8R!V;VED($IO
M:&XH*0T*"7L-"@D)0V]N<V]L92Y7<FET94QI;F4H5'EP92Y'9714>7!E*")3
M>7-T96TN1&%T82Y$871A5&%B;&4L("(@*PT*"0D)"0D)"0D)"2)3>7-T96TN
M1&%T82P@(B K#0H)"0D)"0D)"0D)(E9E<G-I;VX],BXP+C N,"P@(B K#0H)
M"0D)"0D)"0D)(D-U;'1U<F4];F5U=')A;"P@(B K#0H)"0D)"0D)"2 @(")0
K=6)L:6-+97E4;VME;CUB-S=A-6,U-C$Y,S1E,#@Y(BDI.PT*"7T-"GT-"@``
`
end