dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: App crashes when calling .NET Assembly

  1. #1
    Join Date
    May 2003
    Location
    Edinburgh, UK
    Posts
    277

    App crashes when calling .NET Assembly

    not being an expert in C++, I have a C++ app which calls a custom .NET DLL that I made.

    now this works just fine on the dev computer, but when I deploy it, it crashes just when I am trying to get the interface of the assembly.

    OLEViewer DOES see that the DLL is registered, and the registry key does exist but for whatever reason, the app just crashes!

    Code:
    long iResult = -1;
    	HRESULT hr = S_OK;
    	hr = CoInitialize(NULL);
    	if (FAILED(hr) && hr != RPC_E_CHANGED_MODE)
        {
            wprintf(L"\nhr failed initializing (error = %x)\n", hr);
    		
        }
    	wprintf(L"\nNow trying to get the bitlocker interface\n\n");
    	IBitLockerOpsPtr pIBitLocker(__uuidof(BitLockerOps));
    	hr = pIBitLocker->GetBitLockerStatus(&iResult);
    	if (FAILED(hr))
        {
            wprintf(L"\nhr failed when calling GetBitLockerStatus (error = %x)\n", hr);
    		
        }
    	CoUninitialize();
    	return iResult;


    IBitLockerOpsPtr pIBitLocker(__uuidof(BitLockerOps));

    at this point, this is where the app crashes but I have absolutely no idea why, what causes it or what is happening

    any ideas on what I can do?

    on the deployed machine, all the files (the .NET DLL, TLB, C++ app) are in the same folder.
    the .NET DLL is registered in the registry and the OLEViewer CAN see it and i can expand the entry without errors.


    if it helps, here is the TLH:

    Code:
    // Created by Microsoft (R) C/C++ Compiler Version 15.00.21022.08 (dc228a89).
    //
    // C:\Users\User1\AppData\Local\Temp\btbitlocker.tlh
    //
    // C++ source equivalent of Win32 type library BTBitlocker.tlb
    // compiler-generated file created 08/15/09 at 10:05:48 - DO NOT EDIT!
    
    #pragma once
    #pragma pack(push, 8)
    
    #include <comdef.h>
    
    namespace BitLocker {
    
    //
    // Forward references and typedefs
    //
    
    struct __declspec(uuid("1c7b913f-dee3-447a-a168-128b339106e2"))
    /* LIBID */ __BitLocker;
    struct __declspec(uuid("ba1132aa-032b-3f8f-87f7-7b218f88609e"))
    /* dual interface */ IBitLockerOps;
    struct /* coclass */ BitLockerOps;
    struct __declspec(uuid("3e41eb01-c7d8-3db9-9d1f-19840d063ad5"))
    /* dual interface */ _BitLockerOps;
    
    //
    // Smart pointer typedef declarations
    //
    
    _COM_SMARTPTR_TYPEDEF(IBitLockerOps, __uuidof(IBitLockerOps));
    _COM_SMARTPTR_TYPEDEF(_BitLockerOps, __uuidof(_BitLockerOps));
    
    //
    // Type library items
    //
    
    struct __declspec(uuid("ba1132aa-032b-3f8f-87f7-7b218f88609e"))
    IBitLockerOps : IDispatch
    {
        //
        // Raw methods provided by interface
        //
    
          virtual HRESULT __stdcall GetBitLockerStatus (
            /*[out,retval]*/ long * pRetVal ) = 0;
    };
    
    struct __declspec(uuid("d3d5431a-6794-307d-aadc-b5103f8301d0"))
    BitLockerOps;
        // [ default ] interface _BitLockerOps
        // interface _Object
        // interface IBitLockerOps
    
    struct __declspec(uuid("3e41eb01-c7d8-3db9-9d1f-19840d063ad5"))
    _BitLockerOps : IDispatch
    {};
    
    } // namespace BitLocker
    
    #pragma pack(pop)

    d3d5431a-6794-307d-aadc-b5103f8301d0 this is the GUID that is in the registry and what the OLEViewer shows.
    Last edited by Techno; August 15th, 2009 at 08:39 AM.
    C# MVP

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: App crashes when calling .NET Assembly

    What about .NET Framework on the deployed machine?
    Can you call .NET Dll directly using simple C# client, without COM inperop?

  3. #3
    Join Date
    May 2003
    Location
    Edinburgh, UK
    Posts
    277

    Re: App crashes when calling .NET Assembly

    yes I can.

    I added this into the code:

    IBitLockerOpsPtr p = NULL;
    HRESULT hRes = p.CreateInstance(__uuidof(BitLockerOps));


    and get 80040154 on the deployed computer
    Last edited by Techno; August 15th, 2009 at 11:59 AM.
    C# MVP

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)