1

Possible Duplicates:
How to use c# Dll in vc++??
Exporting a native C function from a .net DLL?

I'm writing C# dll that should be hooked to existing application written in C++ that uses dynamic dll loading for plugins. I can't make any changes to C++ application.

I found a lots of tutorials on how to write C# COM dll that will be used in C++ using tlb (static loading), but none on how to write c# dll that will be dynamically loaded (as far as I now, no use of tbl in that case).

So, how to write dll in c# that will c++ application be able to dynamically load?

Dll just need two have two functions with signature:

int Test (char *A, char *B);

result should be returned via second parameter (char *B). That's how function should look if I were writing plugin in c++. I need to make the same thing, but in c#

Community
  • 1
  • 1
bkovacic
  • 371
  • 1
  • 5
  • 16
  • 1
    You do it the same way you would any other COM DLL. There's nothing special about the fact it's written in C# in this case. – Cody Gray - on strike Jun 24 '11 at 12:26
  • @Cody: It sounds like this is NOT COM. – Ben Voigt Jun 24 '11 at 12:49
  • 2
    @Ben: Hmm, the way I read the question it looked like COM. And beyond that, as I understand it, you basically have only two options for sharing C# DLLs with C++. You can either expose the managed C# code as a COM object and interface with it that way, or you can switch to C++/CLI. I think COM is the only option if you must stick with native, unmanaged C++. (Of course, I'd be happy to learn otherwise.) – Cody Gray - on strike Jun 24 '11 at 12:50
  • @Cody: It certainly doesn't help that OP is very confused (thinks a COM TLB is the same as static linking). Anyway, this seems to be an exact duplicate of the question I linked above using "mark as dupe". – Ben Voigt Jun 24 '11 at 12:53
  • @Ben: thanks for the link, I couldn't find it because I was not sure what I'm looking for :( should I be able to view exports with dumpbin.exe /exports command? i don't see anything exported... – bkovacic Jun 24 '11 at 14:42
  • 1
    @pedala: If `dumpbin` shows no exports, then the tool to set the native exports didn't work right. – Ben Voigt Jun 24 '11 at 14:57

0 Answers0