Invoke a .Net Console Application

K

Kishore

Hi,
I have a small console application written in c# that takes two
arguments.
I am using
System.Diagnostics.Process.Start("cmdApp.exe", arguments)
to start the application from another .net application.

But I am unable to start the console application using this method.
When I write a batch file (app.Bat) like:
cmdApp.exe %1 %2
and invoke the batch file from the other application using
System.Diagnostics.Process.Start("app.bat", arguments)
I am able to invoke the console application.

I think this is because a .net application needs mscoree.dll (.Net
execution engine) to execute it.
Is there a way to invoke the .net execution engine and pass the name
of the application as a parameter to it?

How can I invoke the console application from a Win32 application?

Thanks in advance...
Kishore.
 
M

Michael A. Covington

Kishore said:
Hi,
I have a small console application written in c# that takes two
arguments.
I am using
System.Diagnostics.Process.Start("cmdApp.exe", arguments)
to start the application from another .net application.

But I am unable to start the console application using this method.

What happens?
When I write a batch file (app.Bat) like:
cmdApp.exe %1 %2
and invoke the batch file from the other application using
System.Diagnostics.Process.Start("app.bat", arguments)
I am able to invoke the console application.

I think this is because a .net application needs mscoree.dll (.Net
execution engine) to execute it.
Is there a way to invoke the .net execution engine and pass the name
of the application as a parameter to it?

That shouldn't be necessary. If your computer has .NET Framework on it,
your original method should work (although admittedly I haven't tried it).
As far as Windows is concerned, cmdApp.exe is an executable file which calls
mscoree.dll and other DLLs. It loads just like any other .exe, and then
gets involved with .NET stuff when it starts running.

I'm guessing the problem is something entirely different. However, here is
something else to try:

System.Diagnostics.Process.Start("cmd.exe","/c myapp.exe")

(that is probably not the right way to do the arguments, but you know what I
mean). This should do what the BAT does, but without a BAT file.
 

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