LabWindows™/CVI™ Programs Crash When Linked to Mixed-Mode DLLs

Updated Jan 11, 2019

Issue Details

I am writing a program in LabWindows/CVI, and I need to statically link against a mixed-mode DLL. However, when I do this, my program crashes with the following error: 

FATAL RUN-TIME ERROR: Unknown source position, thread id ...: A non-debuggable thread caused a 'General Protection' fault at address... 

How can I statically link to a mixed-mode DLL without crashing my application?


This crash occurs because of the order in which the LabWindows/CVI linker writes imported function information to the imports section of the final executable. LabWindows/CVI 2010 and later exposes a method for changing this order. To fix the crash mentioned previously, LabWindows/CVI must write the imported function information for mixed-mode DLLs before all other DLLs. Complete the following steps to enforce the order in which LabWindows/CVI writes this information:
  1. Close all instances of LabWindows/CVI.
  2. Navigate to the registry key HKCU\Software\National Instruments\CVI\<version>.
  3. Create a new key named DLL Load Order.
  4. Create new string values for the mixed-mode DLLs to which you want to link. Use DLLx, where x is a numeric representation for the load order, as the Name value and the DLL name as the Data value. For example, add the following, depicted registry entries to force the information for mixed-mode DLLs Foo and Bar to be written first and second:
  5. Open LabWindows/CVI and rebuild the application that depends on the mixed-mode DLLs you listed in the registry.

Additional Information

If you are using a version of LabWindows/CVI earlier than 2010, you must explicitly load the mixed-mode DLL using LoadLibrary and GetProcAddress to avoid the crash. Information for explicit linking with DLLs can be found in the Related Links section below.


Not Helpful