Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Error msg In Windows 7: "Unable to load DLL 'Gpib-32.dll': The specified module could not be found."

Solved!
Go to solution

Hi folks, I have a project in VB. NET (VS2010 specifically), which was upgraded from an old VB6 project. The old project 

used Niglobal.bas and Vbib-32.bas  to communicate with the GPIB plugged into one of our scopes. 
Now in the 64 bit Win7, with the Niglobal.bas and Vbib-32.bas converted to Niglobal.vb and Vbib-32.vb, 

I get an error  during debugging at 


Public Sub RegisterGPIBGlobals()   

in the Vbib-32.vb, the error msg says:

 

Unable to load DLL 'Gpib-32.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

 

It looks like this Gpib-32.dll, which I find under SysWOW64 on my Win7, isn't designed for 64bit application, and when I copy this dll file over to 

C:\Windows\System32,  the error msg becomes: 

 

An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

 

 

So I think my question is two fold: 1. When writing my own application in VB.NET  can I still uses Gpib-32.dll (by including Niglobal.vb and Vbib-32.vb )?

2.  Will the application I write with .NET work in x64 Windows 7?

 

Almighty Gurus and Mods please help. Thanks!

0 Kudos
Message 1 of 12
(11,884 Views)

https://www.ni.com/en/support/documentation/supplemental/17/archived--c--and-visual-basic--net-instr...  may be useful

 

http://digital.ni.com/public.nsf/allkb/9D74098B0AFB1D2286256EF40063B3E2 

 

http://digital.ni.com/public.nsf/allkb/4043FBAE3E3CBD3386256D9600538319 

0 Kudos
Message 2 of 12
(11,875 Views)

thx for replying. but the suggestions from the links (Native .NET GPIB Language Interface) are targeting  .NET 1.0 and VS 2005.  I'm on .NET 4 and VS2010.

----------------

I did find some more on this topic.

Someone else also using VB.NET and Windows 7 got this in the reply :

http://forums.ni.com/t5/Measurement-Studio-for-NET/RegisterGpibGlobalsForThread-and-debug-error-on-W...

 

And it seems like I would need to "Switch to the ni4882.dll" if I were to use GPIB in Visual Studio 2010.(Am I right here?) 

Has anyone ever made such changes(from what I understand,   change the program from using  Niglobal.vb and Vbib-32.vb  which leads to gpib-32.dll, to using something that leads to ni42882.dll )?

I see in the NI-488.2 User manual there's this section "Differences Between the GPIB32 API and NI4882 API" but it's assuming I'm using a header called ni488.h and linked to the object gpib-32.obj, which I'm not.

 

 

I guess simply put, my question is:  how do one use new NI4882 API , which uses ni42882.dll? 

0 Kudos
Message 3 of 12
(11,862 Views)

Hello SandiegoSD,

 

The first thing that I would like to check is that you have the latest version of the NI 488.2 drivers which are available here:

https://www.ni.com/en/support/downloads/drivers/download.ni-488-2.html

 

I will continue looking into this error, and please let me know if there are any additional updates or questions regarding this issue.

 

Thanks,

 

Joel

0 Kudos
Message 4 of 12
(11,806 Views)
Solution
Accepted by topic author SandiegoSD

Hey Joel, Thanks for the response! I do have the 3.0.2 driver.

 

I was searching around for quite a while after I posted here and later in the NI4882 user manual ,  page 4-4, I found this:

"To port an application to a 64-bit environment requires that the application migrate to the NI4882 API and be recompiled."

 

So I'm ditching the gpib-32.dll(vbib-32&niglobal) and currently I'm using NI4882.dll and restructuring my project.

 

 

0 Kudos
Message 5 of 12
(11,801 Views)

I am struggling with the same issue, and would prefer not to recode the calls.

One thing that is perplexing is that I can run older VB6 apps that use the gpib-32.dll calls on Windows7 - 64bit with no problem, but if I try to run an app that was written in VB.net using the same calls, it fails on Windows7

 

In all cases the apps work fine of WindowsXP

 

So why does VB6/gpib-32.dll work on WIndows7-64bit?

Why does VB.net/gpib.32.dll fail on WIndows7-64bit?

The environment and the compatibility mode is the same on the executables.

The source code as actually ported from VB6 to VB.net is is very very similar.

 

The VB.net program returns a GPIB not found error.

 

Here is a typical declaration in VB.net that compiles but does not seem to work, but that works fine in VB6

 

   Declare Function ibask32 Lib "gpib-32.dll" Alias "ibask" (ByVal ud As Integer, ByVal opt As Integer, ByRef value As Integer) As Integer

 

 

 

 

 

 

 

0 Kudos
Message 6 of 12
(9,635 Views)

VB6 is a 32-bit system used to develop 32-bit applications and therefore, can use the gpib-32.dll. Whereas when working on a 64-bit OS, vb.NET will, by default, create 64-bit applications which cannot use the gpib-32.dll.  The 32-bit application built by VB6 can run on 64-bit operating systems so therefore I believe this is why one works and the other doesn’t.

 

At the forum below D_Biel explains this and states the three options you have.

http://forums.ni.com/t5/Measurement-Studio-for-NET/RegisterGpibGlobalsForThread-and-debug-error-on-W...

 

“The gpib-32.dll is a 32-bit only DLL (hence the title). So you cannot build a 64-bit application using it. In .NET you have the option of choosing Any CPU which, like you said, determines it's bitness at runtime. This should allow your program to work on a 32-bit system, but not a 64-bit system (assuming it lets you compile, I'm not sure if Visual Studio will notice you are using a 32-bit library). So instead you have a few options:

 

  1. Compile your application as x86 so that it will always run as a 32-bit application, even on a 64-bit system. This should be the simplest method if you are trying to port your existing app because it won't require any code chanes.
  2. Switch to the ni4882.dll instead of gpib-32.dll. This is the newer driver API that includes support for 64-bit applications. This will require some, but little code change.
  3. Switch the the NationalInstruments.NI4882.dll assembly which contains the .NET API. This is probably the best approach for .NET because it is a simpler API to use. However, it will require significant code change because it is using a class library instead of the standard C style library. This is also 64-bit and 32-bit compatible.”

 

Hope this helps.

A Johnson
Applications Engineer
National Instruments
0 Kudos
Message 7 of 12
(9,582 Views)

Have you found your solution. I am having this same problem as you also.

0 Kudos
Message 8 of 12
(9,557 Views)

In this particular case, GPIB-32.dll was being used to create 64 bit applications and this is not possible. You would have to switch to NI4882.dll if you are developing a 64-bit application. 

James F.
Applications Engineer
National Instruments
0 Kudos
Message 9 of 12
(9,523 Views)

 

Ok, I will try to recompile as an x86 app to force 32-bit compatibility.

Will post results once I get a chance.

 

Thanks for the options.

0 Kudos
Message 10 of 12
(9,510 Views)