Urgent... How to invoke a method from an exe file ?

R

RickDee

Hi. I need help badly here.

I need to write a program to invoke methods ( static, public, nonstatic,
with parameters, and etc ) from an exe file, but I keep facing problem.

From all the notes that I read from internet, I realized that InvokeMember
works for methods in class, but not when I have an exe ( right ?).

My program looks like this :

using System.Reflection;

Assembly testAssembly = null;
Form testForm = null;
BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Static | BindingFlags.Instance ;

static void RunApp (object state)
{
Application.Run((Form)state);
}

private void InvokeMethod (Form form, string methodName, params object[]
parms)
{
EventHandler eh =
(EventHandler)Delegate.CreateDelegate(typeof(EventHandler), form,
methodName);
if (eh!=null)
{
form.invoke (eh, parms);
}
}

private void button1_Click (object sender, System.EventArgs e)
{
}
 
M

Michel Walsh

Hi,


You should operate on a window or its control only from its creating
thread; Invoke and BeginInvoke are safe to use from any other thread. The
main question should rather be "did this thread create the form", not "what
is the file extension that defines the form".

I may have not understand your question, on the other hand.

Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top