Groups | Blog | Home
all groups > dotnet interop > december 2006 >

dotnet interop : How to use managed C++ dll in unmanaged code(C++ application).


Willy Denoyette [MVP]
12/7/2006 12:00:00 AM
[quoted text, click to view]

Please read the documentation, more specifically read C++ interop in MSDN
http://msdn2.microsoft.com/en-us/library/ms177552(vs.80).aspx


Willy.


sreelakshmi.rajula NO[at]SPAM gmail.com
12/7/2006 2:08:25 AM
I've a managed c++ dll. How can I use this in unmanaged C++
application.I am using Visual studio 2005.
I read something about regasm....May I know how can I use that?
Thanks in advance.
Regards,
RSL.
sreelakshmi.rajula NO[at]SPAM gmail.com
12/18/2006 4:54:25 AM
Thanks for the information Willy. I've gone through that and also I got
some more information from Google.

Now I've done

// 1. Call CorBindToRuntimeEx
CComPtr<ICorRuntimeHost> spRuntimeHost;
HRESULT hr = 0 ;
hr = CorBindToRuntimeEx(_T("v2.0.50727"), _T("wks"),
STARTUP_LOADER_OPTIMIZATION_SINGLE_DOMAIN | STARTUP_CONCURRENT_GC,
CLSID_CorRuntimeHost, IID_ICorRuntimeHost,
(LPVOID*)(&spRuntimeHost));

//2. Starting the CLR
hr = spRuntimeHost->Start();

//3. Getting _AppDomain interface
CComPtr<IUnknown> spUnk;
hr = spRuntimeHost->GetDefaultDomain(&spUnk);
_AppDomainPtr spDefAppDomain;
hr = spUnk->QueryInterface(&spDefAppDomain);

//4. Getting IDispatch of the managed object (calling GetIDsOfNames on
the
//managed object directly seems to fail. Mangled method names?)
CComPtr<_ObjectHandle> spObjectHandle;
hr = spDefAppDomain->CreateInstance( CComBSTR("GetBLOB"),
CComBSTR("ManagedBLOB::UserSettings"), &spObjectHandle);

But CreateInstance fails ...And the hr shows as "The system cannot find
the file specified."
And the spObjectHandle is null.

I'd be glad to know , If I am doing some thing wrong.
Regards,
RSL.

[quoted text, click to view]
AddThis Social Bookmark Button