Advertisement

09.11.2008 at 12:42PM PDT, ID: 23724383 | Points: 500
[x]
Attachment Details

How to use std::vector inside COM method in c++

Asked by axnst2 in Windows ATL / WTL / COM Programming, C / C++ / C# Editors and IDEs, DCOM

Tags:

I am trying to use a vector on the backside of a COM interface in microsoft visual c++ 6.0.  All compiles and runs....but the return value of the com function is zero.

First I call the below function to add a new sheet to the vector
This function is called internally in the c++ COM dll

void CSheetStore::addSheet(SHEET* sht)
{
  sheetStoreCurrent.addSheet(sht);
}

Then from C#, I call the below function and it always returns zero.

STDMETHODIMP CSheetStore::get_BestSheets(int* cnt)
{
  try
  {
    *cnt = vecBestShts.size();
  }
  catch (Except& x)     { return onError(x); }
  catch (_com_error& x) { return onError(x); }
  return S_OK;
}

I am new to COM but not to using vectors, what am I missing?  I have done this before in non-COM apps with no trouble.Start Free Trial
[+][-]09.11.2008 at 01:10PM PDT, ID: 22454168

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.11.2008 at 01:20PM PDT, ID: 22454275

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.11.2008 at 02:01PM PDT, ID: 22454797

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.11.2008 at 02:18PM PDT, ID: 22455019

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.11.2008 at 02:25PM PDT, ID: 22455115

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2008 at 05:46AM PDT, ID: 22459149

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2008 at 06:24PM PDT, ID: 22465177

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628