I am trying to load C# dll through LoadLibrary. I am able to load it successfully. Can you please tell me how to use GetProcAddress for this dll so that i can use metods and types defined in this dlls.
Thanks in Advance!!!
I am trying to load C# dll through LoadLibrary. I am able to load it successfully. Can you please tell me how to use GetProcAddress for this dll so that i can use metods and types defined in this dlls.
Thanks in Advance!!!
EDIT
1 - Best way for this issue is COM. you should set the AssemblyInfo
to expose the assembly as COM (ComVisible(true)
). See this Microsoft suggestion:
2 - If you have Windows Vista or higher which has bitlocker, BitLocker
can be useful.
3 - But if you cannot using COM, check out this on code-project:
According to this link:
http://social.msdn.microsoft.com/Forums/br/vcmfcatl/thread/cadd6150-de10-47c5-bd5c-a356741c36b3
GetProcAddress will always return NULL for a managed DLL, since it has no exports.
That being said, there are better ways to access managed code from unmanaged code. You should create a C++/CLI wrapper around the unmanaged assembly, and then you can export the managed calls from inside the unmanaged wrapper functions.
Suppose one of your managed functions in class A
is
public static void Foo() {}
You might have C++ code:
DLLEXPORT void FooThunk() {
A::Foo();
}
PS: If anybody out there is comfortable with C++/CLI, please edit my answer to include a better example of such a wrapper.