Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

ni-daqmx example project not working with Visual studio 2019.

I installed NI-DAQmx Drive, I also installed measurement studio support VC2019.

 

But if I run all the example projects provided by DAQmx, DAQmx.dll loader lock exception occurs.

 

If you do not use the class provided in DAQmx.dll, it seems fine.

 

So, if you set to ignore the LoaderLock error in the Debug-Exception menu and run the example, the program does not run.

 

Could it be that the device is not connected?

 

Any solution? Thank you.

Message 1 of 17
(3,682 Views)

I recently had a similar experience using NIDAQmx V21.0. I have a fairly large project that I wanted to update to the latest software versions. It was compiling and working fine with NIDAQmx V20.7. When I updated to NIDAQmx V21.0, the applications (a configuration utility and a Windows service) would lock up cold when instantiating NIDAQmx-related objects. There was VERY LITTLE debug info. I have extensive error handling but it would not get to the point of trapping and displaying the specific errors. One of the clues I had was what you mentioned, the Loader Lock error. I tried disabling that error but debug would not get me any further. Even the Windows event log was really of no help. Finally I reverted to NIDAQmx V20.7 and things started working again. My advice is that you use NIDAQmx V20.7 until there are further updates to V21, or there is further guidance from NI as to why the new driver release is having such an issue, and how to make a change to code or compile settings to avoid a frustrating situation with a lack of debug information like I just experienced.

Message 2 of 17
(3,655 Views)

I used version  21.0 of DAQmx.

 

after i changed version to 20.7.

 

that trouble is clear. 

 

Thanks you.

 

Message 3 of 17
(3,633 Views)

The Loader Lock is something that has cropped up on me in the past year or so in more than one project. While Microsoft always has strongly advised to never call LoadLibrary() inside the DLLMain() function of a DLL, this has always worked in the past although I tried to avoid it in my software. But I have a project or two where I was a little lazy and had done it anyhow. And suddenly last year it would simply start to lock up when I tried to load that DLL (usually in LabVIEW but I tried other methods including directly from a MSVC test program). The only solution was to delay the DLL loading to after the DLLMain() was finished, usually by detecting on strategic calls to my own DLL that the other DLL(s) was/were not yet loaded and do it dynamically there.

 

So while it was never a good idea to do that, it seemed to usually have worked until somewhere last year. I'm not sure which Windows 10 update causes this, or which new Windows behind the back feature. My computer is IT managed and I have no overview of when and which updates are installed and in what order.

Rolf Kalbermatter
My Blog
Message 4 of 17
(3,620 Views)

Hi, thank you for sharing your experience.

 

I lost yesterday one day by trying to update to ver 21.0.

 

Exactly what you wrote in a large project. Now back in 20.70..  😉

 

BR,

Ilkka

Message 5 of 17
(3,581 Views)

 i have same problem  on ver 21

Message 6 of 17
(3,471 Views)

Thanks for posting this and for including the detailed description of this issue.  I'm surprised NI hasn't taken any apparent interest in this yet.  I was looking forward to updating all my systems to DAQmx 21.0 but will hold off now.  I am experiencing this exact issue on a new system running DAQmx 21.0 and will roll it back to 20.7, as others have done on this post, and expect this to fix my problem.  I'll be sure and post here if I don't have success after rolling back to DAQmx 20.7.

Grant M. Johnson
Project Engineer
LECO Corporation
Message 7 of 17
(3,389 Views)

I was putting together a bug report for NI and I put this as steps to reproduce the problem.  When running through the new project wizard, instead of from an existing WinForm project, the 'Loader Lock' issue there is a FileLoadException error with a stack trace that might be useful.  

 

1.) Open Visual Studio
2.) Select Create New Project
3.) Filter on NI
4.) Select NI DAQmx Windows Application
a. National Instruments Error Box appears saying the following error occurred : Could not load file or assembly 'NationalInstruments.DAQmx.dll or one of its dependencies. A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A). Try the following to fix the problem: Contact National Instruments to report this error.
b.) Details
i.) Exception Name : FileLoadException
ii.) Stack Trace:
at NationalInstruments.DAQmx.ComponentModel.Design.DaqUtility.GetMaxTaskNames()
at NationalInstruments.MeasurementStudio.DAQmx.Wizard.DaqAddComponentWizardStepControl.InitializeInterface()
at NationalInstruments.MeasurementStudio.DAQmx.Wizard.DaqAddComponentWizardStepControl..ctor()
at NationalInstruments.MeasurementStudio.DAQmx.Wizard.DaqWizard.AddDaqComponentWizardStep.CreateControl()
at NationalInstruments.MeasurementStudio.WizardFramework.WizardStep.get_Control()
at NationalInstruments.MeasurementStudio.WizardFramework.WizardDialog..ctor(IServiceProvider serviceProvider, String dlgTitle, List`1 wizardSteps)
at NationalInstruments.MeasurementStudio.DAQmx.Wizard.DaqWizard.RunAddDaqComponentWizard()
at NationalInstruments.MeasurementStudio.DAQmx.Wizard.DaqWizard.RunStarted()

Grant M. Johnson
Project Engineer
LECO Corporation
Message 8 of 17
(3,387 Views)

Same problem here with DAQmx 21.0 and Visual Studio 2019. Lost several days trying to read from a USB6000.

Loader Lock exception was being thrown. Masking the exception only caused a crash anyway.

 

As per the advice above, rolled back to 20.7 and all OK.

Thanks for posting.

0 Kudos
Message 9 of 17
(3,369 Views)

?? what is the easiest way to restore 20.7

0 Kudos
Message 10 of 17
(3,309 Views)