Random AccessViolationException when calling IDispatch::Invoke RRS feed

  • Question

  • Hello,

    I have the following problem:

    I have a c++ Dll accessing with COM to a .NET DLL (C#). In most of the cases, everything goes fine, but when my dll is called by some optimized code, and in release mode only, the invoke method gives AccessViolationException

    CComPtr<IDispatch> dispResults = NULL;


    hr = dispResults->GetIDsOfNames(IID_NULL, ....)


    hr = dispResults->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dispparams, &varResult, &excep, &uArgErr);

    When I run my application in debug mode, or in release mode with a debugger, I have no error. The error only occurs when in release mode.

    How can I investigate this error ? Is there any way to make sure the object behind has not been released ?

    Thanks in advance,


    Tuesday, October 6, 2015 12:57 PM