Reputation: 634
I am trying to figure out how this can work:
So here is what I think where the problem is (I could be wrong tho):
How should I do this? Thanks for any suggestions.
Upvotes: 0
Views: 214
Reputation: 48
Your native DLL can be a mixed-mode native-and-.NET assembly, using C++/CLI. Google or search here on "#pragma managed"/"#pragma unmanaged", or look at any of the books on C++/CLI. Basically, assuming you have Visual C++ 2010 or 2012, you can write something like this:
#pragma unmanaged
int main()
{
CallManagedTrampoline();
}
#pragma managed
void CallManagedTrampoline()
{
TypeFromDotnetDLL t = new TypeFromDotnetDLL();
t.CallSomething();
}
In fact, depending on the details of what's in the .NET DLL, you may not even need to put the #pragma managed in front of the CallManagedTrampoline() call--you can sometimes call directly from unmanaged code. C++/CLI is your friend here.
Upvotes: 1
Reputation: 190905
You will have to expose something as COM in your .NET assembly.
Upvotes: 1