AppDomains or New Process

T

Tirumala

Hi Guys,
I have to create a application which loads a external dll and shows a
form from the dll, my requirement is to show the FORM from the dll and close
my application but the Form from the dll should be available for the user.
I thought using AppDomains would solve my problem, but I couldnt find
any proper documentation anywhere. I was able to load and show the form but
when I close the current application everything is closed. So what i
understand from this is when I close my current application the process gets
terminated and as the Appdomain is created under the same process it also
gets terminated. So I will have to load the dll in another process and close
the current process.
If somebody can give suggestions or point so some links would be very
helpful.

Thanks,
Tirumala
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

If you need the form to persist when the main application is closed, you
should indeed launch a separate process to load the DLL and to show the
form.
 
T

Tirumala

Hi Dmitriy,
Thanks for replying..
Now Iam able to load a exe in another process and close my current app.
I have one more question that is Can we load only the dll( not an exe) and
show the form in the Dll ? Because when I load the Dll it opens the
Dependency Walker window showing the dependecies for the loaded dll.

Thanks,
Tirumala


Dmitriy Lapshin said:
Hi,

If you need the form to persist when the main application is closed, you
should indeed launch a separate process to load the DLL and to show the
form.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

Tirumala said:
Hi Guys,
I have to create a application which loads a external dll and
shows
a
form from the dll, my requirement is to show the FORM from the dll and close
my application but the Form from the dll should be available for the user.
I thought using AppDomains would solve my problem, but I couldnt find
any proper documentation anywhere. I was able to load and show the form but
when I close the current application everything is closed. So what i
understand from this is when I close my current application the process gets
terminated and as the Appdomain is created under the same process it also
gets terminated. So I will have to load the dll in another process and close
the current process.
If somebody can give suggestions or point so some links would be very
helpful.

Thanks,
Tirumala
 
T

Tom Porterfield

Tirumala said:
Hi Dmitriy,
Thanks for replying..
Now Iam able to load a exe in another process and close my current app.
I have one more question that is Can we load only the dll( not an exe) and
show the form in the Dll ? Because when I load the Dll it opens the
Dependency Walker window showing the dependecies for the loaded dll.

Dll's need to be hosted in some process. If dependency walker is
installed and configured properly, then it takes over the default action
when double clicking a dll file using the Explorer interface. As
Dmitriy states, you'll need to host the dll in some process separate
from your process if you want it to remain after your process ends.
 
G

Girish Bharadwaj

To add to that, there is an application called rundll32.exe which allows you
to run a unmanaged dll and call an arbitrary function within that. I am sure
you can write one with managed code as well.
Something to the effect of
1. load assembly from the given path.
2. Use reflection to find the method (function/method).
3. Invoke. You can probably make it a bit simpler if the method is a static
method..
 

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