none
Problem using kinect from inside a DLL RRS feed

  • Question

  • Hi ,

    I have created a sample program that load a DLL, call a function in it to  call NuiInitialize, and then another function to call NuiShutdown. After the shutdown, the program crashes.  (if I remove the calls to the kinect sdk functions every thing work fine)

    Attached is the code

    the exe :

    int main () {
    InitFunc _InitFunc;
    ShutdownFunc _ShutdownFunc;
    HINSTANCE hInstLibrary = LoadLibraryA("C:\\Mytest\\MyDll\\Debug\\MyDll.dll");

    if (hInstLibrary)
    {
    _InitFunc = (InitFunc)GetProcAddress(hInstLibrary, "Init");
    _ShutdownFunc = (ShutdownFunc)GetProcAddress(hInstLibrary,"Shutdown");

    if (_InitFunc)
    {
    std::cout << "calling init" << std::endl;
    _InitFunc();
    std::cout << "Init end" << std::endl;
    }
    if (_ShutdownFunc)
    {
    std::cout << "calling Shutdown" << std::endl;
    _ShutdownFunc();
    std::cout << "Shutdown end" << std::endl;
    }

    FreeLibrary(hInstLibrary);
    }
    else
    {
    std::cout << "DLL Failed To Load!" << std::endl;
    }

    std::cout << "Finished!" << std::endl;
    std::cin.get();
    return 0;
    }

    the DLL code:

    extern "C"
    {
    DECLDIR int Init(void )
    {
    HRESULT  hr;
    hr = NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR);
    if ( FAILED(hr) )
    {
    return 0;
    }
    return 1;
    }

    DECLDIR void Shutdown( void )
    {
    NuiShutdown();
    }
    }

    Any suggestions?

    Regards

    Chen

    Sunday, June 10, 2012 2:50 PM

All replies

  • Hi all

    I found out that when I use /clr flag it does not crash anymore... But I need it to work with unmanged code.

    Help anyone?

    Wednesday, June 13, 2012 10:41 AM
  • do you have a crash dump or a callstack of where the crash occurs?
    Friday, June 15, 2012 12:37 AM
  • here is 

    The thread 'Win32 Thread' (0x808) has exited with code 0 (0x0).
    The thread 'Win32 Thread' (0x1218) has exited with code 0 (0x0).
    The thread 'Win32 Thread' (0xc30) has exited with code 0 (0x0).
    The thread 'Win32 Thread' (0xc58) has exited with code 0 (0x0).
    The thread 'Win32 Thread' (0x12c) has exited with code 0 (0x0).
    'LicCleaner.exe': Unloaded 'C:\Mytest\MyDll\Debug\MyDll.dll'
    'LicCleaner.exe': Unloaded 'C:\Windows\SysWOW64\Kinect10.dll'
    'LicCleaner.exe': Unloaded 'C:\Windows\SysWOW64\winusb.dll'
    'LicCleaner.exe': Unloaded 'C:\Windows\SysWOW64\setupapi.dll'
    'LicCleaner.exe': Unloaded 'C:\Windows\SysWOW64\devobj.dll'
    'LicCleaner.exe': Unloaded 'C:\Windows\SysWOW64\msvcp100.dll'
    'LicCleaner.exe': Unloaded 'C:\Windows\SysWOW64\msvcr100.dll'
    'LicCleaner.exe': Unloaded 'C:\Windows\SysWOW64\oleaut32.dll'
    'LicCleaner.exe': Unloaded 'C:\Windows\SysWOW64\ole32.dll'
    'LicCleaner.exe': Unloaded 'C:\Windows\SysWOW64\winmm.dll'
    The thread 'Win32 Thread' (0x115c) has exited with code 0 (0x0).
    First-chance exception at 0x590f6a87 in LicCleaner.exe: 0xC0000005: Access violation.
    Unhandled exception at 0x590f6a87 in LicCleaner.exe: 0xC0000005: Access violation.


    Dump Summary
    ------------
    Dump File: LicCleaner.dmp : C:\MyTests\LicCleaner\Debug\LicCleaner.dmp
    Last Write Time: 6/15/2012 4:29:49 PM
    Process Name: LicCleaner.exe : C:\MyTests\LicCleaner\Debug\LicCleaner.exe
    Process Architecture: x86
    Exception Code: 0xC0000005
    Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
    Heap Information: Present

    System Information
    ------------------
    OS Version: 6.1.7601
    CLR Version(s):

    Modules
    -------
    Module Name Module Path Module Version
    ----------- ----------- --------------
    LicCleaner.exe C:\MyTests\LicCleaner\Debug\LicCleaner.exe 0.0.0.0
    ntdll.dll C:\Windows\SysWOW64\ntdll.dll 6.1.7601.17725
    kernel32.dll C:\Windows\SysWOW64\kernel32.dll 6.1.7601.17651
    KERNELBASE.dll C:\Windows\SysWOW64\KERNELBASE.dll 6.1.7601.17651
    MSVCR100D.dll C:\Windows\System32\MSVCR100D.dll 10.0.30319.460
    msvcrt.dll C:\Windows\SysWOW64\msvcrt.dll 7.0.7601.17744
    user32.dll C:\Windows\SysWOW64\user32.dll 6.1.7601.17514
    gdi32.dll C:\Windows\SysWOW64\gdi32.dll 6.1.7601.17514
    lpk.dll C:\Windows\SysWOW64\lpk.dll 6.1.7600.16385
    usp10.dll C:\Windows\SysWOW64\usp10.dll 1.626.7601.17514
    advapi32.dll C:\Windows\SysWOW64\advapi32.dll 6.1.7601.17514
    sechost.dll C:\Windows\SysWOW64\sechost.dll 6.1.7600.16385
    rpcrt4.dll C:\Windows\SysWOW64\rpcrt4.dll 6.1.7601.17514
    sspicli.dll C:\Windows\SysWOW64\sspicli.dll 6.1.7601.17725
    CRYPTBASE.dll C:\Windows\SysWOW64\CRYPTBASE.dll 6.1.7600.16385
    cfgmgr32.dll C:\Windows\SysWOW64\cfgmgr32.dll 6.1.7601.17621
    crypt32.dll C:\Windows\SysWOW64\crypt32.dll 6.1.7601.17827
    msasn1.dll C:\Windows\SysWOW64\msasn1.dll 6.1.7601.17514
    imm32.dll C:\Windows\System32\imm32.dll 6.1.7601.17514
    msctf.dll C:\Windows\SysWOW64\msctf.dll 6.1.7600.16385
    wintrust.dll C:\Windows\SysWOW64\wintrust.dll 6.1.7601.17787
    uxtheme.dll C:\Windows\System32\uxtheme.dll 6.1.7600.16385
    dwmapi.dll C:\Windows\System32\dwmapi.dll 6.1.7600.16385
    cryptsp.dll C:\Windows\System32\cryptsp.dll 6.1.7600.16385
    rsaenh.dll C:\Windows\System32\rsaenh.dll 6.1.7600.16385

    Hope it will help

    Regards

    Chen

    Friday, June 15, 2012 1:30 PM
  • There is no answer?

    Carmine can you confirm that this is a bug in the SDK?

    Regards

    Chen 

    Sunday, June 24, 2012 4:05 AM