Loading assembly in a seperate process

A

ali.jan

Hi,

It is trivial to load an assembly in a new Application Domain. Is there
any way of loading an assembly in a new process?

I tried using the Process class like this:

Process p = new Process()
p.StartInfo.FileName = mStartupFile
p.StartInfo.UseShellExecute = False
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
p.StartInfo.RedirectStandardOutput = True
p.Start()
string text = p.StandardOutput.ReadToEnd()
p.WaitForExit()

Though this works for exes, it doesn't for DLL assemblies. On my system
Dll is associated with Dependency Walker so it just opens the assembly
up in it.

How would I go about doing a LoadAssembly in a seperate process?

Thanks...

Ali
 
G

Guest

How would I go about doing a LoadAssembly in a seperate process?

You could write a simple EXE that does nothing more than load the DLL you
want and invoke a method in it.


Mattias
 
W

Willy Denoyette [MVP]

Hi,

It is trivial to load an assembly in a new Application Domain. Is there
any way of loading an assembly in a new process?

I tried using the Process class like this:

Process p = new Process()
p.StartInfo.FileName = mStartupFile
p.StartInfo.UseShellExecute = False
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden
p.StartInfo.RedirectStandardOutput = True
p.Start()
string text = p.StandardOutput.ReadToEnd()
p.WaitForExit()

Though this works for exes, it doesn't for DLL assemblies. On my system
Dll is associated with Dependency Walker so it just opens the assembly
up in it.

How would I go about doing a LoadAssembly in a seperate process?

Thanks...

Ali

You can only load assemblies in your own process, not in a spawned process.
So it's up to the spawned process to load the assembly.
What exactly do you wan't to achieve, as I see no use for such remote
assembly loading?

Willy.
 
A

ali.jan

Hi,

I have got a variety of code written in a .net assembly. There is a
workflow engine in C++ that depends a lot on this code. The guys
working on the engine are worried about issues like .NET framework
memory leaks. For example we have been burned once by the XmlSerializer
leak.

So, the engine guys want a mechanism by which they could unload the
assembly and get rid of the .NET memory leaks and then reload it.
Another restriction we have is that the .net assembly has to be loaded
in-process with the engine.

I tried doing this with an Appdomain. I created a new Appdomain and
loaded my assembly in the engine using a proxy etc. Now the assembly
does get unloaded and the Appdomain destroyed but the memory leaked
remains.

So, now I was thinking of loading my assembly out of process... but
that's not allowed either due to several other problems in interaction
with the engine.

It is important to note that we are NOT worried about our own memory
leaks that we could control one way or the other but we are worried
about the leaks in the framework. Is there any solution to this problem
other than dumping .net?

Thanks...

Ali
 
W

Willy Denoyette [MVP]

Hi,

I have got a variety of code written in a .net assembly. There is a
workflow engine in C++ that depends a lot on this code. The guys
working on the engine are worried about issues like .NET framework
memory leaks. For example we have been burned once by the XmlSerializer
leak.
How did you solve it?
So, the engine guys want a mechanism by which they could unload the
assembly and get rid of the .NET memory leaks and then reload it.
Another restriction we have is that the .net assembly has to be loaded
in-process with the engine.

I tried doing this with an Appdomain. I created a new Appdomain and
loaded my assembly in the engine using a proxy etc. Now the assembly
does get unloaded and the Appdomain destroyed but the memory leaked
remains.

What leak? Did you identified the leak?
So, now I was thinking of loading my assembly out of process... but
that's not allowed either due to several other problems in interaction
with the engine.

It is important to note that we are NOT worried about our own memory
leaks that we could control one way or the other but we are worried
about the leaks in the framework. Is there any solution to this problem
other than dumping .net?

Please explain how you can control your own leaks? And what leaks you are
talking about (what kind of memory? Did you run a profiler/debugger to
correctly identify the kindk of leak?.


Willy.
 

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