1

i needed to use a managed dynamic linked library(c#) in my native code(c++).i found the solution here it was. (http://support.microsoft.com/kb/828736).

but the thing that is bothering me is..

1) are managed dynamic linked libraries used in native code through com act as in process com servers ? . if yes how can it be?

2)if no, then how can dynamic linked library act as out process com server without being carried by an executable .

sandeep bisht
  • 111
  • 12

2 Answers2

0

This is an in-proc configuration. It's not much more "impossible" than using P/Invoke mechanism directly. When you run regasm it makes necessary changes to the registry so that when the client calls CoCreateInstance() COM knows that it needs to P/Invoke functions from the corresponding .NET assembly.

sharptooth
  • 167,383
  • 100
  • 513
  • 979
  • "...COM knows that it needs to P/Invoke functions from the corresponding .NET assembly."--it itself proves that new process has to be created ..loading clr and stuf...--->>> out of process – sandeep bisht Oct 15 '13 at 09:26
  • @sandeepbisht: No, you can have CLR loaded into exactly the same process no problem. – sharptooth Oct 15 '13 at 09:35
  • How do you think managed programs call Windows API? They do so in the same address space - inproc. This scenario is the reverse of that one. – sharptooth Oct 15 '13 at 09:59
0
  1. COM knows how to start the CLR for managed DLLs, so this can work for managed DLLs that can run in the appropriate bitness (i.e., AnyCPU or 32/64 bit as appropriate).
  2. For cross-bitness DLLs, I believe that the CLR knows how to start DllHost.exe and run the managed DLL out-of-process. It will be slower, of course.
Eric Brown
  • 13,774
  • 7
  • 30
  • 71
  • thx for ur response .....but does starting clr in itself is not creating a process ? – sandeep bisht Oct 15 '13 at 09:32
  • @sandeepbisht no, starting the CLR doesn't start a process. One can mix native and managed code in a fairly straightforward way. There are issues with CLR startup (it's relatively slow) and in early CLR versions, you couldn't have multiple CLR versions in the same process, but those issues are mostly things of the past. – Eric Brown Oct 15 '13 at 16:17