InpOut32 Win 7 64 bit problem

My x64 port of InpOut32
Post Reply
Anomaly
New User
Posts: 4
Joined: Tue May 14, 2013 12:31 am

InpOut32 Win 7 64 bit problem

Post by Anomaly »

Hello,

I have been using InpOut32 for years and have not had a problem until I tried to run my programs in Win 7 64 bit. The programs were in VB enterprise 2008 and I converted them to VB enterprise 2010 with out any problems.

On Win 7 32 bit
InpOut32.dll is in the /bin/debug directory.
The program runs fine and accesses the parallel port.

On Win 7 64 bit, the program will not run.
I ran the dll installer and InpOutx64.sys was sucessfully installed.
Inpout32.dll is in the sysWoW directory.
When I try to run, I get the following error message.
When the program runs, it errs at the first instance of a call to InpOut32.dll. Any ideas?

System.BadImageFormatException was unhandled
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=z-axis
StackTrace:
at WindowsApplication1.InpOut32_Declarations.Out(Int16 PortAddress, Int16 Value)
at WindowsApplication1.Form1.Button2_Click(Object sender, EventArgs e) in F:\Z-Stack 1.08\z-axis\Form1.vb:line 141
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 82
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Thanks in advance!
User avatar
phil
Site Admin
Posts: 7664
Joined: Sun Apr 06, 2003 11:12 pm

Re: InpOut32 Win 7 64 bit problem

Post by phil »

What version of InpOut are you using?
What on earth is VB enterprise 2010 - you mean VB.NET 2010?
The error is because your trying to either load a 32bit DLL from an x64 process or a x64 DLL from a 32bit process. You have to use the correct DLL.

Be aware that with NET, the program often runs natively on the os architecture. This can be configured in the project settings. I think in 2010 it might force it to 32bit (x86) by default. In this case, you need the 32bit DLL (which in turn loads and talks to the 64bit driver assuming you running my 64bit ports of inpout32).

If however, your running your program natively in x64, you need the x64 dll.

EDIT: From your message, I guess your program is running in x64 mode on x64 windows. So you need to load the x64 DLL not the x86 one.

There are VB.NET and C# examples on my website which shows you how to load the correct DLL at runtime so it works on both x86 and x64 without you needing to worry about what platform your targeting.

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Anomaly
New User
Posts: 4
Joined: Tue May 14, 2013 12:31 am

Re: InpOut32 Win 7 64 bit problem

Post by Anomaly »

Phil,

Thanks for the very quick reply, I didn’t expect that. I must have been half asleep when I wrote about the problem. I meant to say VB 2010 Express, not enterprise.

As I mentioned, the VB program works fine in Win 7 32 bit, but fails in 64 bit. The driver install worked and I put the InpOut32.dll into the sysWoW directory. I am assuming from your comments that I need to do something to cause the program to run in the 32 bit mode. I will work on this and report back after working on it some more.

Thanks!
User avatar
phil
Site Admin
Posts: 7664
Joined: Sun Apr 06, 2003 11:12 pm

Re: InpOut32 Win 7 64 bit problem

Post by phil »

Either change the project settings...
Right click project, properties, compile, advanced compile options (right at the bottom), Target CPU -> x86

OR use the 64bit DLL when running in x64, or the 32bit dll when running in x86 - see the vb.net example on my website.

Thanks,
Phil
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Anomaly
New User
Posts: 4
Joined: Tue May 14, 2013 12:31 am

Re: InpOut32 Win 7 64 bit problem

Post by Anomaly »

Phil,

Your advise got me going in the right direction. I just solved the problem and the program now runs in Win 7 64 bit. I found out that VB Express does not expose the target property inside the development environment. The solution was to edit the project file to include <PlatformTarget>x86</PlatformTarget> . There may be other ways to do this, but it works.

Again, thank you for your incredibly fast response and help.
User avatar
phil
Site Admin
Posts: 7664
Joined: Sun Apr 06, 2003 11:12 pm

Re: InpOut32 Win 7 64 bit problem

Post by phil »

Ah OK I didnt realise Express didnt give the option (I checked in my full blown VS).
Glad its working though :)
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Post Reply