It's unusual to want to close the form associated with the main executable,
but if you must close that form then there are several ways of doing it.
Probably the simplest way is to hide it. You can do this from any of your
other forms as long as they have access to a reference to your "main" form.
To ensure they do have a reference you could provide them each with a
constructor that takes a reference to the main form (plus any other
parameters you may need to pass in).
So, when your main form opens a dialog it could say:
MyDialog md = new MyDialog(this);
md.Show(); // or md.Visible = false;
Then in the dialog constructor, you can say:
public class MyDialog : Form // or whatever
{
private MainForm mf;
public MyDialog(MainForm mf)
{
// other constructor stuff
this.mf = mf;
mf.Visible = false; // Hide the main form or mf.Hide();
// other constructor stuff
}
...
}
HTH
Peter
"TonyJ" <jo*****************@telia.comwrote in message
news:eh**************@TK2MSFTNGP03.phx.gbl...
Hello!!
I just wonder about one thing. Assume I have one main and several dll as
you
mentioned and I open a dialog in one dll and
then I want to close down the executable(exe.-file)
How is this done?
//Tony
"Peter Bradley" <pb******@uwic.ac.ukskrev i meddelandet
news:#A**************@TK2MSFTNGP02.phx.gbl...
>By the way, why are you building all these separate executables? Why
don't
>you just build a main class that has the application entry point, and
several class libraries (DLLs) that you can reference? Then you won't
need
>all this IPC stuff.
Is there some reason that they must be running in separate executable
assemblies? Do they have to run on separate machines, for instance?
Maybe you're just worried about making sure that all the other classes
all
use the same instance of your error handling class, for some reason? If
so,
>just pass a reference to it to its clients.
Peter
"Peter Bradley" <pb******@uwic.ac.ukwrote in message
news:%2***************@TK2MSFTNGP03.phx.gbl...
You need remoting - either the .NET Remoting Framework kind or via Web
services, I would think:
http://msdn2.microsoft.com/en-us/library/kwdt6w2k.aspx
http://msdn2.microsoft.com/en-us/library/kwdt6w2k.aspx
Peter
"TonyJ" <jo*****************@telia.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
Hello!
Assume I have several exe files running and all these constitute the
actual
application.
To be able to log errors and different types of trace my intention is
to
>have a separate exe file that take care of the actual writing to a
file.
>Between the exe files(application) and the exe file that is handle the
writing of errors and trace my intention is to use interprocess
communication.
I have used interprocesscommunication when I worked with C++ but not
in
C#.
Now I wonder can anybody give me a hint about where to find some
example
>about which classes and so on to use for this matter.
By the way is interprocesscommunication the best way to send message
between
processes when working with C#.
//Tony