Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CreateInstance(__uuidof(MYClass));

CreateInstance(__uuidof(MYClass));

Scheduled Pinned Locked Moved C / C++ / MFC
csharpcomquestionc++performance
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KeithF
    wrote on last edited by
    #1

    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 Response

    void main()
    {
    short blnRetVal = 0; //Set to False Initially, return value from dll

    IChVReqPtr 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

    K 1 Reply Last reply
    0
    • K KeithF

      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 Response

      void main()
      {
      short blnRetVal = 0; //Set to False Initially, return value from dll

      IChVReqPtr 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

      K Offline
      K Offline
      KeithF
      wrote on last edited by
      #2

      Anybody?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups