Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
4 ratings:
 3 out of 5   

LabWindows™/CVI™ Programs Linking to Mixed-Mode DLLs Crash

Primary Software:
Primary Software Version: 2009
Primary Software Fixed Version: N/A
Secondary Software: N/A

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.
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.

Related Links:
KnowledgeBase 37AF2I86: LabWindows/CVI Application Fails to Execute on Windows XP Service Pack 2 with Remote Execution Security Enabled
Developer Zone Tutorial: Calling a DLL in CVI: Explicit Linking vs. Implicit Linking (Dynamic vs. Static)


Report Date: 09/30/2010
Last Updated: 03/17/2015
Document ID: 5DTDHRXU

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit