Hi,
Is it possible to late bind to a dll written in C# from VB6? If so, does
anyone have an example.
It's possible but you need somehow instantiate this object. mscoree.dll
exposes undocumented ClrCreateManagedInstance function, it's declared in
mscoree.h as the following:
STDAPI ClrCreateManagedInstance(LPCWSTR pTypeName, REFIID riid, void
**ppObject);
and C++ usage:
HRESULT hr = ClrCreateManagedInstance(L"ClrTestLib.CFoo, ClrTestLib,
Version=1.0.1207.27541, Culture=neutral, PublicKeyToken=a8c61b7e4c98192e",
IID_IUnknown, reinterpret_cast<void**>(&spUnk));
Or you can use technique described in "Microsoft .NET: Implement a Custom
Common Language Runtime Host for Your Managed App" MSDN Magazine article to
create CLR by CorBindToRuntimeEx call, then Start it, and then create or
retrieve default domain by ICorRuntimeHost::CreateDomain/GetDefaultDomain,
and after use it to instantiate class instance - e.g.
AppDomain.CreateInstanceFrom.
...
Cheers,
Vadim.