Click here to Skip to main content
15,887,302 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
Questionproblem communicating between managed and unmanaged code inside a dll Pin
mtestt8-Sep-11 5:32
mtestt8-Sep-11 5:32 
AnswerRe: problem communicating between managed and unmanaged code inside a dll Pin
Richard Andrew x649-Sep-11 13:56
professionalRichard Andrew x649-Sep-11 13:56 
Questionhooking winsock send function Pin
vkgktm24-Aug-11 1:31
vkgktm24-Aug-11 1:31 
QuestionWeird problem using C++ dll from vb6 Pin
lenourien22-Aug-11 15:57
lenourien22-Aug-11 15:57 
AnswerRe: Weird problem using C++ dll from vb6 Pin
Richard Andrew x6422-Aug-11 16:22
professionalRichard Andrew x6422-Aug-11 16:22 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien22-Aug-11 17:35
lenourien22-Aug-11 17:35 
GeneralRe: Weird problem using C++ dll from vb6 Pin
Richard MacCutchan22-Aug-11 23:06
mveRichard MacCutchan22-Aug-11 23:06 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien22-Aug-11 23:23
lenourien22-Aug-11 23:23 
Hello,
thank you for your answer. Actually I reached the same conclusion, I think I am not properly releasing the variant array that's returned to the vb app.
But I don't know what I'm doing wrong.

inside the class it is declared:
VB
static VARIANT pVal;


then it is initialized outside the class with:
VARIANT MYCLASS::pVal;


in my code I do
C#
VariantInit(&pVal);
pVal.vt= VT_ARRAY|VT_BYREF|VT_BSTR;
pVal.pparray = &pSA;
return pVal;


If I'm not mistaken, the return pval; is where the problem occurs.

My deconstructor is:

C#
MYCLASS::~MYCLASS()
{
    SafeArrayDestroy(pSA);

    if (pVal.vt & VT_BYREF) {

        if (*pVal.pbstrVal != 0) {
        ::SysFreeString(*pVal.pbstrVal);
        }

        if (pVal.bstrVal != 0) {
        ::SysFreeString(pVal.bstrVal);
        }

    }

    VariantClear(&pVal);

}


I step throught it in the debugger everything in the deconstructor is used so I really assumed it was all ok. But obviously something is still hanging around. I read that "If the variant was used to explicitly pass a pointer, i.e. (vt & VT_BYREF != 0), then free the memory pointed to." I think that's what I'm doing.

Anyway, once again, I'm so lost.

Thanks again for helping
GeneralRe: Weird problem using C++ dll from vb6 Pin
Richard MacCutchan23-Aug-11 0:05
mveRichard MacCutchan23-Aug-11 0:05 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien23-Aug-11 0:10
lenourien23-Aug-11 0:10 
GeneralRe: Weird problem using C++ dll from vb6 Pin
Richard MacCutchan23-Aug-11 0:12
mveRichard MacCutchan23-Aug-11 0:12 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien23-Aug-11 2:55
lenourien23-Aug-11 2:55 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien23-Aug-11 5:05
lenourien23-Aug-11 5:05 
AnswerRe: Weird problem using C++ dll from vb6 Pin
MicroVirus23-Aug-11 5:24
MicroVirus23-Aug-11 5:24 
GeneralRe: Weird problem using C++ dll from vb6 Pin
Richard MacCutchan23-Aug-11 5:51
mveRichard MacCutchan23-Aug-11 5:51 
AnswerRe: Weird problem using C++ dll from vb6 Pin
MicroVirus23-Aug-11 5:18
MicroVirus23-Aug-11 5:18 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien23-Aug-11 13:33
lenourien23-Aug-11 13:33 
QuestionRe: Weird problem using C++ dll from vb6 Pin
MicroVirus23-Aug-11 15:22
MicroVirus23-Aug-11 15:22 
AnswerRe: Weird problem using C++ dll from vb6 Pin
lenourien24-Aug-11 4:17
lenourien24-Aug-11 4:17 
AnswerRe: Weird problem using C++ dll from vb6 Pin
MicroVirus24-Aug-11 17:41
MicroVirus24-Aug-11 17:41 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien25-Aug-11 1:31
lenourien25-Aug-11 1:31 
GeneralRe: Weird problem using C++ dll from vb6 Pin
MicroVirus25-Aug-11 3:25
MicroVirus25-Aug-11 3:25 
GeneralRe: Weird problem using C++ dll from vb6 Pin
lenourien25-Aug-11 12:39
lenourien25-Aug-11 12:39 
QuestionWTSSendMessage fails as RPC Server is unavailable Pin
Arun Parthasarathy22-Aug-11 1:24
Arun Parthasarathy22-Aug-11 1:24 
AnswerRe: WTSSendMessage fails as RPC Server is unavailable Pin
Tony Richards25-Aug-11 13:05
Tony Richards25-Aug-11 13:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.