[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Dynamic class creation at runtime

(Dan)

7/1/2002 6:31:00 PM

Could anyone tell me how I can dynamically build a class at runtime
and then create an instance of it. I think the answer lies in the
System.Reflection namespace but I am unsure about how to use these
classes (MethodBuilder.CreateMethodBody - what is MSIL and how do I
create it?). I am greatful of any help that can be given to me.
Thanks!
1 Answer

Lloyd Dupont

7/3/2002 2:14:00 PM

0

here is a very simple sample....
of course you have to learn IL.....

"Dan" <DMudge@Ethitec.com> a écrit dans le message de news:
e5d8880b.0207010753.2604d733@posting.google.com...
> Could anyone tell me how I can dynamically build a class at runtime
> and then create an instance of it. I think the answer lies in the
> System.Reflection namespace but I am unsure about how to use these
> classes (MethodBuilder.CreateMethodBody - what is MSIL and how do I
> create it?). I am greatful of any help that can be given to me.
> Thanks!


begin 666 emiter.cs
M=7-I;F<@4WES=&5M.PT*=7-I;F<@4WES=&5M+E)E9FQE8W1I;VX[#0IU<VEN
M9R!3>7-T96TN4F5F;&5C=&EO;BY%;6ET.PT*=7-I;F<@4WES=&5M+E1H<F5A
M9&EN9SL-"@T*+R\@8W)E871E(&%N(&]B:F5C="!P97)F;W)M:6YG(&%N(&%D
M9&ET:6]N#0HO+R!C<V,@96UI=&5R+F-S("8F(&5M:71E<@T*<'5B;&EC(&EN
M=&5R9F%C92!!9&0-"GL-"@EF;&]A="!A9&0H9FQO870@82P@9FQO870@8BD[
M#0I]#0H-"G!U8FQI8R!C;&%S<R!%;6ET97(-"GL-"@EP=6)L:6,@<W1A=&EC
M('9O:60@36%I;BA3=')I;F=;72!A<F<I#0H)>PT*"0EF;W(H:6YT(&D],3L@
M:3PV.R!I*RLI#0H)"7L-"@D)"4%D9"!A(#T@0W)E871E*"D[#0H)"0E#;VYS
M;VQE+E=R:71E3&EN92AA+F%D9"AI+"!I*2D[#0H)"7T-"@E]#0H)#0H)<'5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