Hi all,
I have a C++/CLI console application and I should pass a CComPtr<T> to a class but when I try to access it, occours a System.AccessViolationException.
Following the main code:
And following the CameraHook.h and CameraHook.cpp:
When the console reachs auga->p->SetCameraIDispatch(), it breaks.
What's the problem?
Thanks a lot!
Marco
I have a C++/CLI console application and I should pass a CComPtr<T> to a class but when I try to access it, occours a System.AccessViolationException.
Following the main code:
Code:
CComPtr<IAuga> auga;
CLSID clsAuga;
HRESULT hr = CLSIDFromProgID(L"Heimdall.Auga.1", &clsAuga);
if (hr > -1)
{
hr = CoCreateInstance(clsAuga, NULL, CLSCTX_INPROC_SERVER, __uuidof (IAuga), (void**)&auga);
if (hr > -1)
{
printf("Auga COM component created successfully!\n");
}
else
{
//error
}
}
CameraHook^ cam = gcnew CameraHook((CComPtr<IAuga>*&)auga);
cam->StartCamera();
Code:
ref class CameraHook
{
private:
CComPtr<IAuga> *auga;
public:
CameraHook(CComPtr<IAuga> *ag);
void StartCamera();
};
Code:
CameraHook::CameraHook(CComPtr<IAuga> *ag)
{
auga = ag;
}
void CameraHook::StartCamera()
{
HRESULT hr = auga->p->SetCameraIDispatch(........);
}
When the console reachs auga->p->SetCameraIDispatch(), it breaks.
What's the problem?
Thanks a lot!
Marco