Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET DAQmx dll x64 assembly will throw System.AccessViolationException when calling "DaqSystem.Local.GetPhysicalChannels"

Solved!
Go to solution

I'm trying to develop a WPF application in .NET7 on VS2022 that uses DAQmx library.

I referenced -

  • NationalInstruments.DAQmx.dll (Version 23.5.45.49381, the one that is under the directory 'Assemblies (64-bit)')
  • NationalInstruments.Common.dll (Version 19.1.40)

Then, when the project's target platform is set to x64, the application crashes when it calls DaqSystem.Local.GetPhysicalChannels with a "System.AccessViolationException". This happen only when I run the program from the IDE. If I play the program straight from the "bin" folder, it runs nicely.

 

If I reference x86 version of DAQmx.dll and the project's target platform is set to x86, then the program runs both within the IDE and straight from the "bin" folder.

 

I want to keep developing the application with x64 target platform.

Any suggestions?

Message 1 of 7
(1,506 Views)

I am having the same issue here also. Not able to target x64. Have you found a solution?

Message 2 of 7
(1,447 Views)

I get that too, been trying to get around it for a couple of weeks, any update on that?

Message 3 of 7
(1,407 Views)
Solution
Accepted by MendelBen

NI-DAQmx is NOT yet .Net Core compatible. It requires the .Net Framework 4 to run. If you want to run in .Net Core you will have to target the according C DLL directly through .Net Interop.

 

Here is a possible start for a C# Interop layer to DAQmx: https://github.com/jrdnwrth/NetDAQmx

And here is the NI-VISA variant: https://github.com/jrdnwrth/NetVisa

 

Rolf Kalbermatter
My Blog
Message 4 of 7
(1,375 Views)

Thanks for the reply!
But here's the strange thing - even the ni-DAQmx example solutions (Which runs on .NET framework 4.5) behave in the exact same way.

0 Kudos
Message 5 of 7
(1,368 Views)

Not sure if it has to do with the Visual Studio version. I am using Visual Studio Community 2015 and NI-DAQmx 2023 Q2. 

I can debug the shipping example without any issues. The default setting builds with 64-bit.

ZYOng_0-1694216245887.png

 

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 6 of 7
(1,318 Views)

Hey Rolf, thanks for the answer.

 

Just note, I did use the example you presented from Github.

The same issue still persist when I configure VS to work on x64 platform. I.e., when I call any of the functions from the NI dll, a System.AccessViolationException is thrown.

 

 

0 Kudos
Message 7 of 7
(1,103 Views)