How can i create a control object (System.Windows.Forms.dll) using CreateInstance

  • Thread starter Thread starter babylon
  • Start date Start date
B

babylon

I tried
System.Reflection.Assembly a =
System.Reflection.Assembly.Load("System.Windows.Forms.dll");
and
System.Reflection.Assembly
GetAssembly(System.Type.GetType("System.Windows.Forms.CheckBox"));

dont' work...
any clue?
thx!
 
may be you wrote it wrong in this post by mistake.

But a possible correct way seems to be

System.Reflection.Assembly a =
System.Reflection.Assembly.Load("System.Windows.Forms.dll");
a.CreateInstance("System.Windows.Forms.CheckBox");

Best regards
Shashank
 
I can do it using
System.Reflection.Assembly.LoadWithPartialName("System.Windows.Forms");
but not
System.Reflection.Assembly.Load("System.Windows.Forms.dll");

how come...
 
I can do it using
System.Reflection.Assembly.LoadWithPartialName("System.Windows.Forms");
but not
System.Reflection.Assembly.Load("System.Windows.Forms.dll");

how come...

1. Specify the assembly name, not the assembly file name. I.e.
"System.Windows.Forms", not "System.Windows.Forms.dll".

2. System.Windows.Forms has a strong name and resides in the GAC. Therefore,
you have to reference it using its strong name.

Fabian
 
Back
Top