473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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

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(Event Handler), form,
methodName);
if (eh!=null)
{
form.invoke (eh, parms);
}
}

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


Nov 16 '05 #1
1 1572
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

"RickDee" <ch***********@agilent.com> wrote in message
news:uC**************@TK2MSFTNGP11.phx.gbl...
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(Event Handler), form,
methodName);
if (eh!=null)
{
form.invoke (eh, parms);
}
}

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


Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Altland | last post by:
Here is my basic problem. I have a form that executes a cpu instensive algorithm occupying the first thread. When the algorithm is executed another form pops up telling the user the progress that...
4
by: Ahmet | last post by:
Hi all; I have one application in which I read form names from database to be opened. I open form with the code below, and call its show method for form to be shown but before this, I must set...
0
by: Bsiang Tan | last post by:
Dear all experts, I have this: An assembly (proxy.dll) which is a WebService proxcy client Case 1 : Loading proxy.dll using Assembly.LoadFrom(...), invoke a static method of a class which...
5
by: RickDee | last post by:
Please help, anybody. I am trying to write a program so that it can launch an exe file ( which is also genereated in C# ) and then simulate the button clicking and invoke the methods inside the...
3
by: Simon King | last post by:
I have created a service which uses the FileSystemWatcher to monitor folders for file changes. I have a app.config file which specifies which folders to watch and what to do when a change occurs. ...
2
by: Chandrakant Shinde | last post by:
Hi there, I want to copy a Image to the clipboard. When i try to do so following exception occurs : "The current thread must set to Single Thread Apartment (STA) mode before OLE calls can be...
7
by: stephan querengaesser | last post by:
hi ng, i try to invoke a webservice-method with an filter-object, that contains value types. if i don´t want to filter the return value of the method, i have to pass a new instance of the...
6
by: ajit | last post by:
I am working on web service which in turn call com components. if # of users using the web service increases. Web service fails is there some why I can prevent max # of concurrent users using the...
1
by: roadbai | last post by:
Hi all, This is the first time to post question here, hopefully experts of perl here can give me a hand, to be honest, I am kind of new to perl, and I am struggling with the "Out of memory" issue I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.