Error Code (0xc0000142) with an MFC Application Calling a LabVIEW DLLPrimary Software: LabVIEW Run-Time EnginePrimary Software Version: 5.0 Primary Software Fixed Version: N/A Secondary Software: Measurement Studio>>Visual C++ Support
Problem: I made a DLL in LabVIEW, and when I try to statically link it in an MFC C++ application, I get an error saying "The application failed to initialize properly (0xc0000142). Click on OK to terminate the application". I can call this same LabVIEW DLL from LabVIEW or a Win32 application without any errors. How can if fix this? ![]() Solution: This error occurs in the MFC application because the MFC application tries to load your LabVIEW DLL into memory before the application loads important system libraries into memory (such as User32.dll). Your LabVIEW DLL will make calls into these system libraries, and if they are not in memory, your LabVIEW DLL will throw an error when it is being loaded. In the Win32 Console application type, your LabVIEW DLL is loaded after the system libraries by default, thus no error. To fix this, you must either call your LabVIEW DLL dynamically, or you need to set the delay load option to delay the loading of your LabVIEW DLL. To set the delay load option in Visual Studios, open the project properties and navigate to Configuration Properties » Linker » Input and type in the name of your LabVIEW DLL in the Delay Loaded DLLs field, as shown below where Sum.dll is your LabVIEW DLL. ![]() To call your LabVIEW DLL dynamically, see the MSDN link below for an example of how to call a DLL dynamically. You would also need to remove Sum.lib from your Additional Dependencies in the above picture. Related Links: MSDN: Using Run-Time Dynamic Linking Attachments:
Report Date: 09/02/2008 Last Updated: 09/10/2008 Document ID: 4P1D2AQX |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


