CreateInstance(__uuidof(MYClass));
-
Folks Quick Question: I have a dll developed in c#, which does some interactions with a web service, this all seems to be fine. I have made the dll visible to COM. I then register the dll using regasm passing it a /codebase /tlb argument. Again all this works fine. I now get a tlb file. From here i reference the tlb in my VC6 project like so:
// Import the type library.
#import "C:\\epos\\MyInterface.tlb" raw_interfaces_only
using namespace MyInterface;Once i compile the VC++ project i get a tlh file generated, which has the following contents (edited there is much more in this file just showing what is needed here): .tlh File generated by VC6
#pragma once
#pragma pack(push, 8)#include <comdef.h>
namespace MyInterface {
struct __declspec(uuid("2172ffe3-3177-3e81-ac7a-9d27e11be389"))
/* dual interface */ IMyLink;
struct /* coclass */ CMyLink;_COM_SMARTPTR_TYPEDEF(IMyLink, __uuidof(IMyLink));
I create COM earlier in the program so i have not included it in the code below. Then i Create an instance of the c# class, to call the methods i need. Now this all works fine and i can call these methods and they work correctly. Code in my Main.c file
IMyLinkPtr iPtrMyLink; //Global Variable
IChVRspPtr iPtrCheckVRsp; //Create the Interface to The CheckVoucher Responsevoid main()
{
short blnRetVal = 0; //Set to False Initially, return value from dllIChVReqPtr iPtrCheckV(\_\_uuidof(CChVReq)); //Create the Interface to The Method1 Class. This is another class in the dll HRESULT hrRetval= E\_FAIL; hrRetval = iPtrMyLink.CreateInstance(\_\_uuidof(CMyLink)); //This is the main class in the dll, a wrapper to call methods from.
// Pass to the method the request class, a reference to the response class and a reference to the return value.
iPtrMyLink->CallMethod1(iPtrCheckV, &iPtrCheckVRsp, &blnRetVal);
}The problem i am having is that my program crashes after some time where the memory has grown to 32mb, which to me is quite low. The crash occurs on a CreateInstance line, not necessarily the one above but some other method i have to another .net dll. My main question is about memory, before calling this line:
hrRetval = iPtrMyLink.CreateInstance(__uuidof(CMyLink));
The memory in the VC6 app is 12mb, once this line is called the memory jumps to 24mb. Is this down to loading the .net Fra
-
Folks Quick Question: I have a dll developed in c#, which does some interactions with a web service, this all seems to be fine. I have made the dll visible to COM. I then register the dll using regasm passing it a /codebase /tlb argument. Again all this works fine. I now get a tlb file. From here i reference the tlb in my VC6 project like so:
// Import the type library.
#import "C:\\epos\\MyInterface.tlb" raw_interfaces_only
using namespace MyInterface;Once i compile the VC++ project i get a tlh file generated, which has the following contents (edited there is much more in this file just showing what is needed here): .tlh File generated by VC6
#pragma once
#pragma pack(push, 8)#include <comdef.h>
namespace MyInterface {
struct __declspec(uuid("2172ffe3-3177-3e81-ac7a-9d27e11be389"))
/* dual interface */ IMyLink;
struct /* coclass */ CMyLink;_COM_SMARTPTR_TYPEDEF(IMyLink, __uuidof(IMyLink));
I create COM earlier in the program so i have not included it in the code below. Then i Create an instance of the c# class, to call the methods i need. Now this all works fine and i can call these methods and they work correctly. Code in my Main.c file
IMyLinkPtr iPtrMyLink; //Global Variable
IChVRspPtr iPtrCheckVRsp; //Create the Interface to The CheckVoucher Responsevoid main()
{
short blnRetVal = 0; //Set to False Initially, return value from dllIChVReqPtr iPtrCheckV(\_\_uuidof(CChVReq)); //Create the Interface to The Method1 Class. This is another class in the dll HRESULT hrRetval= E\_FAIL; hrRetval = iPtrMyLink.CreateInstance(\_\_uuidof(CMyLink)); //This is the main class in the dll, a wrapper to call methods from.
// Pass to the method the request class, a reference to the response class and a reference to the return value.
iPtrMyLink->CallMethod1(iPtrCheckV, &iPtrCheckVRsp, &blnRetVal);
}The problem i am having is that my program crashes after some time where the memory has grown to 32mb, which to me is quite low. The crash occurs on a CreateInstance line, not necessarily the one above but some other method i have to another .net dll. My main question is about memory, before calling this line:
hrRetval = iPtrMyLink.CreateInstance(__uuidof(CMyLink));
The memory in the VC6 app is 12mb, once this line is called the memory jumps to 24mb. Is this down to loading the .net Fra