1

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!!!

Rohit Garg
  • 101
  • 1
  • 2
  • 5

2 Answers2

1

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:

Ria
  • 10,237
  • 3
  • 33
  • 60
0

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.

Michael Graczyk
  • 4,905
  • 2
  • 22
  • 34