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.
Code:
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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.