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

  • Thread starter Thread starter RickDee
  • Start date Start date
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)
{
}
 
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
 
Back
Top