473,698 Members | 2,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stand alone Executable return argument

Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates their
Md5 sets.
This application is used by other applications in my dept, which simply call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny

Nov 16 '05 #1
6 8840
Sunny,

You really aren't going to be able to pass a value back through the
executable. The best you could do is pass an integer back to the process
that triggered you.

If possible, you should refactor this code out into a component, and
integrate that component into the other applications that need it. It would
be easy enough to expose this as a .NET and a COM component, which should
allow you to access it from almost anywhere.

If you need to keep this as an executable, then you might want to
consider having it write out files to another directory, which you can
relate to the original files, which have the MD5 hash in them, or store the
hashes in some other persistant format (like a database) where the other
applications can get to it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Sunny" <Su***@discussi ons.microsoft.c om> wrote in message
news:61******** *************** ***********@mic rosoft.com...
Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates
their
Md5 sets.
This application is used by other applications in my dept, which simply
call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished
working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny

Nov 16 '05 #2
I appreciate all the help, I am in fact writing out a set of Xml files at
this time as my work process and at the end of the process i am infact
invoking a third application that in turns (indirectly) signals to my caller
as a signal of my work completion. However this app is being used almost by
all the other apps and i have been told to return a signal to the caller that
i have finished my work in addition to the files written out, since they
don't always want to go and read the files as such.

But I think there has got to be a way for the. static void main(string[]
args) to return some signal values to their callers, this simply defies all
logic that this is not prossible in this scenario...
would look forward to any more suggestions. . .

Thanks for the Help,

With Regards
Sunny

"Nicholas Paldino [.NET/C# MVP]" wrote:
Sunny,

You really aren't going to be able to pass a value back through the
executable. The best you could do is pass an integer back to the process
that triggered you.

If possible, you should refactor this code out into a component, and
integrate that component into the other applications that need it. It would
be easy enough to expose this as a .NET and a COM component, which should
allow you to access it from almost anywhere.

If you need to keep this as an executable, then you might want to
consider having it write out files to another directory, which you can
relate to the original files, which have the MD5 hash in them, or store the
hashes in some other persistant format (like a database) where the other
applications can get to it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Sunny" <Su***@discussi ons.microsoft.c om> wrote in message
news:61******** *************** ***********@mic rosoft.com...
Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates
their
Md5 sets.
This application is used by other applications in my dept, which simply
call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished
working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny


Nov 16 '05 #3
Just change public static void main to public static int main, and return
whever error code you want to return to the process. Then any other process
running your EXE can check the return code.

--Bob

"Sunny" <Su***@discussi ons.microsoft.c om> wrote in message
news:61******** *************** ***********@mic rosoft.com...
Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates
their
Md5 sets.
This application is used by other applications in my dept, which simply
call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished
working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny

Nov 16 '05 #4
Hi Nicholas great to see you finally after a long time.
Thanks for the info, infact i am writing out an xml file as my work process
and at the end my app is invoking a third application that signals to my
caller as a signal of my work completion, but this app is being used by a lot
of apps in my dept and there is a req now that it must return a signal value
so that the caller does not always have to go and check something else to
find out if i have finished.
I was thinking there would be a better way to return a status signal to the
callers even in a static void main implementations

public static void main(string[] args)
{
//All the work
myInternalClass mc = new myInternalClass (args);
//Now finished and return something
}

Thanks for all the help, and welcome for more suggestions. ..

With Regards
Sunny

"Nicholas Paldino [.NET/C# MVP]" wrote:
Sunny,

You really aren't going to be able to pass a value back through the
executable. The best you could do is pass an integer back to the process
that triggered you.

If possible, you should refactor this code out into a component, and
integrate that component into the other applications that need it. It would
be easy enough to expose this as a .NET and a COM component, which should
allow you to access it from almost anywhere.

If you need to keep this as an executable, then you might want to
consider having it write out files to another directory, which you can
relate to the original files, which have the MD5 hash in them, or store the
hashes in some other persistant format (like a database) where the other
applications can get to it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Sunny" <Su***@discussi ons.microsoft.c om> wrote in message
news:61******** *************** ***********@mic rosoft.com...
Hi,
I have a very serious issue at hand. I have created a small C# Console App
(Csd.exe) that collects a list of files as its argument and generates
their
Md5 sets.
This application is used by other applications in my dept, which simply
call
this Csd.exe app and passing a list of files.
I want to ask how can I return a value from this Csd.exe application as an
indicator or a signal to the calling app that Csd.exe has finished
working.
The problem is that the main component of my Csd.exe is a

public static void main(string[] args)
{
//All the work
//And that is it (done)!
//Here i want to enter a return int or a bool (true) so that the caller
can know
//that i am finished processing....
}

The Static void main does not let me return anything. How can i do that.

Please HELP!

Thanks and Regards
Sunny


Nov 16 '05 #5
Sunny,

You could do a number of things, but you won't be able to get a return
value back through the parameters, or through the return value. The entry
point for the application can only return an integer (which does not meet
your needs) and it can not modify the command line arguments. Any signal
that you send (perhaps an event, not the kind in .NET, but the
synchronization object) would have to be something that the other programs
actively listen for.

Because of these needs, it really is a better idea if you place it in a
component and have the clients or something else call the component. This
way, you can be more sure when the method completes, (instead of waiting for
an event, you just wait until the method call completes).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Sunny" <Su***@discussi ons.microsoft.c om> wrote in message
news:EF******** *************** ***********@mic rosoft.com...
I appreciate all the help, I am in fact writing out a set of Xml files at
this time as my work process and at the end of the process i am infact
invoking a third application that in turns (indirectly) signals to my
caller
as a signal of my work completion. However this app is being used almost
by
all the other apps and i have been told to return a signal to the caller
that
i have finished my work in addition to the files written out, since they
don't always want to go and read the files as such.

But I think there has got to be a way for the. static void main(string[]
args) to return some signal values to their callers, this simply defies
all
logic that this is not prossible in this scenario...
would look forward to any more suggestions. . .

Thanks for the Help,

With Regards
Sunny

"Nicholas Paldino [.NET/C# MVP]" wrote:
Sunny,

You really aren't going to be able to pass a value back through the
executable. The best you could do is pass an integer back to the process
that triggered you.

If possible, you should refactor this code out into a component, and
integrate that component into the other applications that need it. It
would
be easy enough to expose this as a .NET and a COM component, which should
allow you to access it from almost anywhere.

If you need to keep this as an executable, then you might want to
consider having it write out files to another directory, which you can
relate to the original files, which have the MD5 hash in them, or store
the
hashes in some other persistant format (like a database) where the other
applications can get to it.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Sunny" <Su***@discussi ons.microsoft.c om> wrote in message
news:61******** *************** ***********@mic rosoft.com...
> Hi,
> I have a very serious issue at hand. I have created a small C# Console
> App
> (Csd.exe) that collects a list of files as its argument and generates
> their
> Md5 sets.
> This application is used by other applications in my dept, which simply
> call
> this Csd.exe app and passing a list of files.
> I want to ask how can I return a value from this Csd.exe application as
> an
> indicator or a signal to the calling app that Csd.exe has finished
> working.
> The problem is that the main component of my Csd.exe is a
>
> public static void main(string[] args)
> {
> //All the work
> //And that is it (done)!
> //Here i want to enter a return int or a bool (true) so that the
> caller
> can know
> //that i am finished processing....
> }
>
> The Static void main does not let me return anything. How can i do
> that.
>
> Please HELP!
>
> Thanks and Regards
> Sunny
>


Nov 16 '05 #6
Hi Sunny,
The Static void main does not let me return anything. How can i do that.


Main method can return an integer. The caller can check the return value
using its prcess handler or in realm of .NET using object of the Process
class.

If you only want to signal when the *exe* finish you have options. Look at
the Process class
You are going to use that class either to start the *exe* or to attach to
already running one.

Then your options are:
1. To block the caller until the other process finishes -
Process.WaitFor Exit and then if you need to check Process.ExitCod e, which is
whatever integer the *exe*'s main method returns
2. To check periodically Porcess.HasExit ed and if it has to get the ExitCode
3. To hook on Exited event. It will be fired as soon as the process exits.
And then again you can check its ExitCode.

Even thought the process may exited long time ago its ExitCode will stay
valid until you dispose the process object (or close the process handle in
terms of Win32 API).

You can dispose the process by call its Dispose or you can leave this to the
the GC.

If you need to communicate big chunk of data, though, what you can do is
either to use files, or redirect the standart input and output. I believe
that using sockets or .NET remoting isn't worth it. Actually, do you have
some options here as well.

--
HTH
Stoitcho Goutsev (100) [C# MVP]

Nov 16 '05 #7

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

Similar topics

5
1386
by: Tom | last post by:
Hi folks, (note: Newbie post) I have inherited the code maintenance and development of an existing internal webservice written in c#. It's a fairly standard client, appserver, dbserver architecture and essentially determines an employees to do list. I has been developed in Visual studio, which is new for me as well. I am required to add the ability for the application to email reminders to
121
9757
by: David Pendrey | last post by:
I was wondering if it is at all posible to write a stand alone .EXE program in Visual Studio .NET. Hopefully in VB.NET but if not another language would be ok. Thanks for the assistance
16
3027
by: Roman Yankin | last post by:
Hello All, Is there a way to compile C# windows application as a stand alone program? In my univ class we don't have VS.NET installed and I need to have my executable running with out .NET environment. Is it possible? As i'm getting the following error:
13
1544
by: Brett | last post by:
Ok, we all know a stand alone .NET EXE isn't possible, unless you want to shell out $4k (see previous post with similar subject). Frankly, I don't. Given that, what are the options for VB programmers? 1. There's VB6. One acronym and one word: DLL Hell (tip of the hat to Microsoft for this one). 2. There's learn Java, which is slow and has a really funky interface. Why do that any way if you know you'll always be on a Win machine. ...
7
4726
by: Ulrich Wisser | last post by:
Hi, I would like to stop the postmaster every night and run vacuum pg_dump reindex in the stand alone backend.
2
2326
by: jim-on-linux | last post by:
py help, The file below will run as a stand alone file. It works fine as it is. But, when I call it from another module it locks my computer, The off switch is the only salvation. This module when run as a stand alone, it will
7
1733
by: David S. Zuza | last post by:
Does anybody know if it is possible to develop stand alone vb2005 apps that require no install and could be run from a flash drive or cd? If so I am trying to figure it out. thanx in advance.
1
1387
by: samfori | last post by:
i'm just new and i want to know how to build a stand alone program (executable)from scripts of C++ code i.e. from .h and .cpp files
2
2001
by: Zehra Ali | last post by:
I was wondering if anyone knew how one could go about developing a stand alone executable version of a web based application written in Java . Currently we are using Net beans platform. The website for the application is: (http://designadvisor.mit.edu/design/ ). I heard c# might be of some use. I would really appreciate any guidelines or references Thanks, Zehra
0
8609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.