Were experimenting with getting access to the members of a program and using the methods and properties in them. Would use it to later use the functions/properties by reading a file and use them at runtime. But got a problem. Can make it work if it only has to do with the form, by using 'this' as the parameter(See mark*) but don´t know how to access others members except writing it directly in code, but that´s not what I want to.
Assembly addon = null;
addon = Assembly.GetExecutingAssembly();
Type[] tp = addon.GetTypes();
FieldInfo tl = tp[1].GetField("toolStripButton1");
Type tg = tl.FieldType;

PropertyInfo pI = tg.GetProperty("Text");
object[] param = new object[1];
param[0] = "Test";
This line * pI.SetValue(this.toolStripButton1, param[0], null);

Hope you can help. Hope the code isn´t to hard to understand. When writing some 'idea' code I usually use fast var names.

9 Years
Discussion Span
Last Post by sknake

Can you post a sample project? I don't understand your problem here. You have not declared toolStripButton1 in the scope of the code you posted and i'm guessing you have a tool strip button in the class this code is in, and you are actually reflecting in to your local toolstrip and not the reflected assembly.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.