How to send data back to dll from EXE....?

  • Thread starter Thread starter Phani
  • Start date Start date
P

Phani

Hi,

I am Developing an WindowsExe UI application Say "WindowsExe1.exe"
which inturn calls a ClassLibrary dll "Test.dll".The Test.dll calls
another WindowsExe UI application say "WindowsExe2.exe".

I have Written Code in Test.dll as

AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.ExecuteAssembly("WindowsExe2.exe");

every thing working fine till now..

1)I Had a Exit Button in WindowsExe2.exe UI, Here is the Code for
exit button
private void Exit_Click(object sender, System.EventArgs e)
{
Application.Exit();
}

1)My first problem is when i click exit Button on WindowsExe2.exe
application all the applications(WindowsExe1.exe,WindowsExe2.exe) are
Closing..
But i want to close only WindowsExe2.exe and set the focus back to
WindowsExe1.exe..How can i do that..
2)My second Problem is.. i need to pass Some Data from Test.dll to
WindowsExe2.exe.. while Calling ,..I thought of Passing that data as
command line Args for WindowsExe2.exe ... is it the Right
approach..?(What are all the Best ways doing this) if it is how to
pass command line Args *****any Sample Code Please... ****
3)my third problem is i need to Send data back From WindowsExe2.exe
to Test.dll Before Closing WindowsExe2.exe ... How to do this ...what
are all the Possible approaches for this.. do i need to do Remoting
for this Problem..
Do i need Delegates ...?

one more Note:*****
WindowsExe1.exe is creating several Instances of Test.dll ****

Can any one help me what all the Best solutions for this...

Thanks,
 
Hello Phani,

It appears, from your message, that you are writing all three components.
It seems odd to me that you would want to do what you are doing. Why not
just have two windows in the same application? If you need the process
separation, I'd understand, but otherwise, it seems like wild overkill
(Killing a fly with a cruise missile).

Anyway, sending command line arguments is not difficult.
currentDomain.ExecuteAssembly("WindowsExe2.exe", new Evidence(null),
"argument1", "argument2");

getting back information is quite a bit harder. You can send it back if you
have a separate thread in the "host" application that is monitoring a
service call or web service. Otherwise, you could write to a file that the
sender knows to pick up.

As far as calling Application.Exit... if your WindowsExe2.exe is a windows
application, this is a bad way to exit. Close all the forms with
MyForm.Close() before calling this. In fact, you should be able to do away
with the Application.Exit call altogether. It is usually not needed.

I hope this information is useful. If I knew more about what these
applications are doing, I may be able to be more helpful.

--- Nick Malik
 
Back
Top