Results 1 to 9 of 9

Thread: start VB DLL in C++EXE

  1. #1

    Thread Starter
    Addicted Member BarankinBeAMan's Avatar
    Join Date
    Aug 2002
    Location
    Reston,Va
    Posts
    164

    Red face start VB DLL in C++EXE

    How do I start VB DLL in C++EXE in debug mode?

    If I run EXE, it calls VB dll with no problem.

    But in VB debug mode, when I start vb application,
    C++ executable starts with no problem, then when I call vb DLL from there, I get error, dll does not get created.
    Is that VB known bug or me doing it wrong ?

  2. #2
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    VB dll's require the VB run-time & VB virtual machine to be activated, plus, VB-made dll's are COM objects, so you have to call CoInitialize();

  3. #3

    Thread Starter
    Addicted Member BarankinBeAMan's Avatar
    Join Date
    Aug 2002
    Location
    Reston,Va
    Posts
    164
    Here is what I do:

    HRESULT hresult;
    CLSID clsid;

    CoInitialize(NULL); //initialize COM library
    hresult=CLSIDFromProgID(OLESTR("ValidateCard.Validate"), &clsid); //retrieve CLSID of component

    _Validate *t;
    hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_SERVER,__uuidof(_Validate),(LPVOID *) &t);
    if(FAILED(hresult))
    {
    AfxMessageBox("Creation Failed");
    return;
    }
    ______________________________________________

    and this works fine when I run C++ code.
    But it Failes to create object if I run it from vb Code.
    How do you run it from vb to debug it ?


  4. #4
    Frenzied Member
    Join Date
    Jul 2002
    Posts
    1,370
    In your VB project, set a reference to the .dll, .OCX or .EXE.

    Code:
    Dim vcard as New Validate  ' assuming the class name is validate
    ............... mess with it here
    Is this what you mean?
    You can check to make sure what the class is by using F2 - the Object Browser, after you have added the reference.

  5. #5

    Thread Starter
    Addicted Member BarankinBeAMan's Avatar
    Join Date
    Aug 2002
    Location
    Reston,Va
    Posts
    164
    The problem is, in vb debug mode, vb class function does not even get called.
    C++ exe gets executed first, and before it even calls
    vb function, it fails to create vb object.

    But while running the same compiled VB dll and calling the same vb function, the object creation does not fail.
    There has to be some way to run VB code in debug mode successfully.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You could create a small VB exe for test purposes only.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7

    Thread Starter
    Addicted Member BarankinBeAMan's Avatar
    Join Date
    Aug 2002
    Location
    Reston,Va
    Posts
    164

    VB exe

    I tried that, It works fine with VB exe too, as well as in Debug mode.
    I think in case of using C++ exe and VB dll in debug mode,
    there has to be some options in C++ project, or some certain dll declaration in c++, so VB function could be called not only in run time, but in debug mode too.

  8. #8

    Thread Starter
    Addicted Member BarankinBeAMan's Avatar
    Join Date
    Aug 2002
    Location
    Reston,Va
    Posts
    164

    Resolved

    Binary Compatability option in VB project properties
    had to be checked.
    Now it works.
    Otherwise, VB function never gets called in Design Mode.



  9. #9
    Hyperactive Member tumblingdown's Avatar
    Join Date
    Mar 2000
    Posts
    362
    I'm sure you're aware of this, but if you compile your vb project with debug symbols, you can step thru the vb code from the c++ debugger.


    td.
    "One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig


    [email protected]

    "but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width