I was of the opinion that the unmanaged C++ CRT only initialized the CLR when the code was compiled to use CLR. I was also under
the impression that this would only happen in the EXE not in a DLL. Now it appears that my impressions and understandings are not
at all right, so the question now becomes.
In the case of a STRICTLY unmanaged EXE (not compiled to use CLR) calling a managed (Mixed Mode in this case) C++ DLL, does the
runtime initialize the CLR on every call into the DLL or does it do it once in DLL main (or the equivalent)?
Second question, is why is this such a mystery? I have not found any documentation from MS that would EVEN SUGGESTS that this
approach works. All of their documentation talks about calling CorBindToRuntimeEx from the unmanaged code and then doing COM like
things to find interface pointers.
In a nut shell, what are the trade-off between what appears to be a reverse It Just Works method of calling managed code from
unmanaged vs. explicitly hosting the CLR as is (almost) documented by Microsoft?
>Hi Roy,
>
[quoted text clipped - 11 lines]
>bye
>Rob
-------------------------------------------
Roy Chastain
KMSystems, Inc.
Robert Jordan - 27 Oct 2004 14:02 GMT
Hi Roy,
> In the case of a STRICTLY unmanaged EXE (not compiled to use CLR) calling a managed (Mixed Mode in this case) C++ DLL, does the
> runtime initialize the CLR on every call into the DLL or does it do it once in DLL main (or the equivalent)?
The CLR will be initialized once per process, AFIK.
> Second question, is why is this such a mystery? I have not found any documentation from MS that would EVEN SUGGESTS that this
> approach works. All of their documentation talks about calling CorBindToRuntimeEx from the unmanaged code and then doing COM like
> things to find interface pointers.
There is no mistery ;-) It's just a checkbox of your project properties.
However, there are some problems with MC++ DLLs:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/ht
ml/vcconMixedDLLLoadingProblem.asp
> In a nut shell, what are the trade-off between what appears to be a reverse It Just Works method of calling managed code from
> unmanaged vs. explicitly hosting the CLR as is (almost) documented by Microsoft?
The hosting interface is intended to be used from VS 6 or from
other unmanaged languages (Borland C++, Delphi, etc.).
bye
Rob