How can the dll be unmapped from the address space?

G

Guest

Hi!

I call a native Dll in my C# application (platform invoke). How can the dll
be unmapped from the address space. I want to modify the dll file before
closing the application. I have found Freelibrary function, but how can it be
used in C#?

Thanks,

Frankie
 
G

Guest

You can't. The DLL gets loaded by the runtime and there is no provision for
telling it to unload. You might tell us why you think you need to modify a
DLL and we might have alternate ideas. There are only a couple reasons I
can think of for doing this.
 
G

Guest

I write a compiler. The native DLL mentioned by my question is produced by my
C# application. And after producing it is called by the app to test it, after
that I want to generate a modified dll

Thank you for your answer

Frankie
 
P

Paul G. Tobey [eMVP]

You could load the DLL, not by referencing it via P/Invoke, but by calling
LoadLibrary(), GetProcAddress(), and FreeLibrary(). That should cause it to
be properly unloaded, but, of course, it might be a bit of a challenge to
arrange the proper calling sequence for a function with a random signature
in managed code.

Paul T.
 
G

Guest

Thank you. It works

Frankie

Paul G. Tobey said:
You could load the DLL, not by referencing it via P/Invoke, but by calling
LoadLibrary(), GetProcAddress(), and FreeLibrary(). That should cause it to
be properly unloaded, but, of course, it might be a bit of a challenge to
arrange the proper calling sequence for a function with a random signature
in managed code.

Paul T.
 

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