COM client crashes calling COM method 
Author Message
 COM client crashes calling COM method

My Win32 console app can't return from a call to COM component. Debugging through
the COM component yields a successful passing of parameters from the client, but
attempting to return to the client yields a "User breakpoint called from code at
0x77f9f9df". Attempting to run past this point repeats the same message over and
over. Here's the client code:

        CoInitialize(0);
        // Other initializations.
        {  // Extra scope level here, so smart pointers are released prior to
                BLOWFISHCOM2Lib::ICryptoPtr pCrypto;
                // the 'Ptr' suffix implies a smart-pointer wrapper.
                if (SUCCEEDED(pCrypto.CreateInstance(CLSID_Crypto)))
                {       // work with the object.
                        ICrypto *ptr = pCrypto.GetInterfacePtr();
                        char in[256], out[256];
                        memset(out,0,256);
                        strcpy(in, "This is a test...");

                        ptr->blowfish((BSTR) in, (BSTR) out, 1, (BSTR) "2343");
// never returns from above COM call
                        char tmp[256];
                        sprintf(tmp,"%s",out);

                }
        // smart pointer automagically releases com object after this brace...
        }
        CoUninitialize();



Fri, 06 Jun 2003 08:58:18 GMT  
 COM client crashes calling COM method
You should not be using cast's when passing BSTR parameters....in fact , in
your sample code you are not passing BSTR's at all (but using casting to
shut up the compiler attempting to warn you about your error).

Your "in" and "out" parameter should not be array's of char but should be
allocated BSTR (using one of the BSTR smart types or using SysAllocString
explicitly).

You cannot pass a string literal and use a cast to fool the compiler into
thinking it is a BSTR.

Peter Partch


My Win32 console app can't return from a call to COM component. Debugging
through
the COM component yields a successful passing of parameters from the client,
but
attempting to return to the client yields a "User breakpoint called from
code at
0x77f9f9df". Attempting to run past this point repeats the same message over
and
over. Here's the client code:

CoInitialize(0);
// Other initializations.
{  // Extra scope level here, so smart pointers are released prior to
BLOWFISHCOM2Lib::ICryptoPtr pCrypto;
// the 'Ptr' suffix implies a smart-pointer wrapper.
if (SUCCEEDED(pCrypto.CreateInstance(CLSID_Crypto)))
{ // work with the object.
ICrypto *ptr = pCrypto.GetInterfacePtr();
char in[256], out[256];
memset(out,0,256);
strcpy(in, "This is a test...");

ptr->blowfish((BSTR) in, (BSTR) out, 1, (BSTR) "2343");
// never returns from above COM call
char tmp[256];
sprintf(tmp,"%s",out);

Quote:
}

// smart pointer automagically releases com object after this brace...
Quote:
}

CoUninitialize();


Fri, 06 Jun 2003 09:32:36 GMT  
 COM client crashes calling COM method

Quote:
> You cannot pass a string literal and use a cast to fool the compiler into
> thinking it is a BSTR.

Well, yes you can - as indicated by the now missing error message.  It is
the computer that can't be fooled :-)

Vincent Minden


Quote:
> You should not be using cast's when passing BSTR parameters....in fact ,
in
> your sample code you are not passing BSTR's at all (but using casting to
> shut up the compiler attempting to warn you about your error).

> Your "in" and "out" parameter should not be array's of char but should be
> allocated BSTR (using one of the BSTR smart types or using SysAllocString
> explicitly).

> You cannot pass a string literal and use a cast to fool the compiler into
> thinking it is a BSTR.

> Peter Partch



> My Win32 console app can't return from a call to COM component. Debugging
> through
> the COM component yields a successful passing of parameters from the
client,
> but
> attempting to return to the client yields a "User breakpoint called from
> code at
> 0x77f9f9df". Attempting to run past this point repeats the same message
over
> and
> over. Here's the client code:

> CoInitialize(0);
> // Other initializations.
> {  // Extra scope level here, so smart pointers are released prior to
> BLOWFISHCOM2Lib::ICryptoPtr pCrypto;
> // the 'Ptr' suffix implies a smart-pointer wrapper.
> if (SUCCEEDED(pCrypto.CreateInstance(CLSID_Crypto)))
> { // work with the object.
> ICrypto *ptr = pCrypto.GetInterfacePtr();
> char in[256], out[256];
> memset(out,0,256);
> strcpy(in, "This is a test...");

> ptr->blowfish((BSTR) in, (BSTR) out, 1, (BSTR) "2343");
> // never returns from above COM call
> char tmp[256];
> sprintf(tmp,"%s",out);

> }
> // smart pointer automagically releases com object after this brace...
> }
> CoUninitialize();



Sat, 07 Jun 2003 12:59:38 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Enable COM clients call methods inside COM events

2. Calling COM method from managed c++ client

3. Problem calling VB COM dll from VC++ multithreaded COM EXE client

4. Calling a COM call back object's method fails if it is in Windows 98

5. problems passing ADO Recordset from VB-COM client to VC-COM-Server dll

6. COM/ATL novice:passing object pointers through methods on a COM interface

7. Return a pointer to a nested COM object from a COM object method

8. Please Help - How to get the Client ID inside a COM server function call

9. COM inproc crashes when calling GetMessage/PeekMessage

10. Calling methods through a late-bound COM object in C#

11. Displaying a dialog from a COM server method - prevents calling application from repainting

12. calling a method in a J++ COM DLL from C++

 

 
Powered by phpBB® Forum Software