all groups > dotnet interop > august 2005 >
You're in the

dotnet interop

group:

loading umanaged dll in c#


loading umanaged dll in c# uzi
8/4/2005 10:41:54 PM
dotnet interop: Hi



I have a project that requires me to load the same unmanaged dll multiple
times.



I though of trying to define a managed assembly that points to the extern
c++ functions, and load it into separate AppDomain. The problem is that the
unmanaged dll has static variables, and my test proved that the dll is
loaded once per process.



I need to find a way to load the unmanaged dll more then once in an isolated
memory space in the same process.



Any ideas?



Uzi



Re: loading umanaged dll in c# Ben Rush
8/7/2005 1:39:06 AM
Uzi,

I would be suprised if you actually can do this even in the unmanaged
universe (load multiple copies of the same DLL into your address space)
short of some hacked-up form of manual memory mapping or simply calling out
to the filesystem to copy the module on disk and load all copies dynamically
(copy, rename, load, copy, rename, load, etc.) . This seems like a poorly
designed solution. I would step back and refactor the problem as I don't
think it's possible to do what you want to do - my spidey sense tells me
you're gonna be in for a world of hurt if you keep down this path...

--
Ben Rush
http://www.ben-rush.net/blog/
http://www.littlebigendian.com/



[quoted text, click to view]

Re: loading umanaged dll in c# uzi
8/7/2005 10:48:04 AM
Hi

thanks for the reply.

the problem is that i work with legacy c++ dll, and this dll opens a socket,
and i need it to work with multiple end points.

i cannot open or change the source of this dll. so this is what i have to
work with.

anyway, since loading it multiple times is the best option, i thought of
loading multiple processes to achive this.

Regards
Uzi


[quoted text, click to view]

Re: loading umanaged dll in c# Willy Denoyette [MVP]
8/8/2005 12:00:00 AM
You can't load an unmanaged DLL more than once per process, what exactly do
you wan't to achieve?

Willy.

[quoted text, click to view]

Re: loading umanaged dll in c# Jeremy Chapman
8/8/2005 1:29:25 PM
We had to do the same thing. Our solution was to create a small exe which
loads one copy of the dll into memory and exposes it's methods through
remoting. We then run multiple instances of that exe, and create a main
application which can communicate to all the exe instances through remoting.
Works great, but there may be a better simpler solution.

[quoted text, click to view]

AddThis Social Bookmark Button