Hi,
I want to achieve the following
I have a MFC Application. This Application on click of button should load a COM dll (say MyDLL.dll) MyDLL.dll is a private assembly which is NOT registered.
I have the following piece of code segment:
actCtx.cbSize = sizeof(ACTCTX);
actCtx.lpSource = _T("C:\\SampleProject1.manifest");
actCtx.dwFlags = ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID;
actCtx.lpAssemblyDirectory = _T("C:\\Sample");
HANDLE hCtx = ::CreateActCtx(&actCtx);
if (hCtx == INVALID_HANDLE_VALUE)
{
MessageBox(
NULL,
_T("INVALID_HANDLE_VALUE"),
"Error Message",
MB_OK
);
hCtx = NULL;
}
else
{
if (::ActivateActCtx(hCtx, &cookie))
{
::CoInitialize(NULL);
hr = ::CoCreateInstance(CLSID_MyClass, NULL, CLSCTX_INPROC, IID_IDispatch, (void**)&ptrMyDisp);
ptrMyDisp->QueryInterface(IID_IMyClass,(void **)&ptrMyClass);
ptrMyClass->Add(1,2);
::DeactivateActCtx(0,cookie);
::ReleaseActCtx(hCtx);
hCtx = NULL;
}
}
SampleProject1.manifest contains a reference to MYDLL.dll
My MFC application executes from C:\MFCApplication\Release folder. If I place MYDLL.dll at C:\MFCApplication\Release folder things work correctly.
However I intend to keep the various dlls at some other place. Thus I have specified probing path as C:\Sample. However if I remove the dlls from C:\MFCApplication folder and place them only at C:\Sample the application returns "Class Not Registered error" after CoCreateInstance().
How do I provide a probing path for my private assembly dlls
--------------------------------------------------------------------------------