> Home > Computer Q & A

Q:  I am running into this strange error.
I have written a C++ EXE, that calls a VB DLL. I compiled the EXE and eveything was fine. (It was calling the DLL Methods).

Now I have to deploy the EXE and the DLL to a different Server. That is where the problem cames in.
I copied the C++ EXE and the DLL and ran "regsvr32" to register the DLL.
When i Execute the EXE on the Server, I get a "Access Violation" Error and the whole application bombs.

Can anyone help me with this ? I am trying to find a way to deploy the application on different Servers and I am badly stuck due to this.

The code I used in the C++ program to call the VB DLL is :
#import "GMServer.dll"  no_namespace

int main()
{
       BSTR bstrDesc;
    HRESULT hresult;
    char input[70];
    CLSID clsid;
 
    try
       {
         CoInitialize(NULL);        
         strcpy(input,"Something");
      
      hresult = CLSIDFromProgID(OLESTR  ("GMServer.Kit"),&clsid);
    
     _Kit *ptr;
   
     hresult = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(_Kit), (LPVOID *)&ptr);

    if (FAILED(hresult))
          printf("FAILED TO INITIALIZE");


    double version = ptr->ConvertFile(input,1);
    cout << " THE RETURN CODE IS = " << version <<   endl;
    }
     catch(_com_error &e)
     {
       bstrDesc = e.Description();
     }
   CoUninitialize();
}

(I keep getting the "FAILED TO INITIALIZE" Error)

Thanks for any help.
Kenny.

A: 

I would change:

_Kit *ptr;

to

_KitPtr ptr;

and then

hresult = CoCreateInstance(...)

to

hresult = ptr.CreateInstance(__uuidof(Kit));