How can the dll be unmapped from the address space?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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
 
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.
 
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.
 
Back
Top