Page 1 of 1

Inpoutx64 and VB.Net 2010

Posted: Thu Mar 10, 2011 9:55 pm
by PaulT
I am trying to access my parallel port (genuine on-board LPT1 at &H378) using Inpoutx64 with VB.Net 2010 on a Windows 7, 64-bit PC. I am getting the following error when I attempt to output data to the port:

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

I am not sure I have the dll in the correct location - currently trying the bin/debug folder in the VB project. I have tried adding a reference to the dll but that fails. Where am I going wrong?

Thanks.

Re: Inpoutx64 and VB.Net 2010

Posted: Thu Mar 10, 2011 10:03 pm
by phil
That exception means your trying to use a 64bit dll in a 32bit process or the other way round.

If your in 32bit application you must use the 32bit DLL (inpout32.dll)
If your in 64bit application, you must use the 64bit DLL (inpoutx64.dll)

Visual Studio 2010 by default compiles in 32bit mode. Prior to 2010 the default was "Any CPU" which means if the CPU & OS can run x64, the app will run in x64 mode, otherwise 32bit mode (which made it diffuclt because you never knew at runtime what "bitness" your app would be.

The .NET samples on my website work out, at runtime, which DLL to use - this is the safest thing to do in .NET. The alternate is to specify the bitness (target CPU) in your project settings. As said, the default for VS2010 is 32bit)

EDIT: the dll(s) should be in the same folder as the EXE (or in the system path somewhere).

I hope that helps (and is clear?) :)
Thanks,
Phil

Re: Inpoutx64 and VB.Net 2010

Posted: Thu Mar 10, 2011 10:20 pm
by PaulT
Thanks Phil. That was quick. I'll go check that now.

Can you also point me to "The .NET samples on my website".

Many thanks,

Paul.

Re: Inpoutx64 and VB.Net 2010

Posted: Thu Mar 10, 2011 10:22 pm
by phil
The page is here:
http://www.highrez.co.uk/Downloads/InpOut32/default.htm

The link is labeled .NET 2.0 (2005) Example code.
They should work in VS 2005, 2008 and 2010.

The links to the latest binaries are also on that page. I suggest you use at least v1.2.0.0 because it contains signed drivers (required for windows vista and later).

Thanks,
Phil

Re: Inpoutx64 and VB.Net 2010

Posted: Thu Mar 10, 2011 10:42 pm
by PaulT
Thanks Phil. I downloaded your example and after changing the m_bX64 boolean to "true" it runs with no errors but does not seem to write anything to the port. I am checking with a multimeter and I'm 99% sure I have the correct pins ;-)

I'm not missing anything silly am I? Print spooler service doesn't need to be stopped? Does port mode matter? I'm currently using ECP mode as I hope to use some handshaking eventually. The port is a "genuine" on-board parallel port (not a PCI card) and is at the default address of &H378.

Thanks.

Re: Inpoutx64 and VB.Net 2010

Posted: Thu Mar 10, 2011 10:48 pm
by phil
Urm, not sure why it isnt working - but I thought m_bX64 was set dynamically depending on the runtime environment.

Does the PC speaker example button work (should make a noise)?
NOTE: If the VB example does not have a pc speaker test button, then there is a newer version somewhere (let me know).

The parallel port is more difficult for me to answer because my knowledge there is >10 years old and very rusty. Whats worse, I dont have a parallel port on my board to test it.

If I recall correctly some parallel ports require driver resistors to tie them but usually its to tie them "low" or off so I would expect you to see something with your multimeter. Have you tried all 8 output pins? Is the port in 8bit output mode? I dont know how much ECP/EPP etc makes a difference, but I seem to recall having issues with those modes - I htink you have more work and to mess arround with other regiesters. Its probably worth putting the port in standard mode just to test if it makes any difference)

Thanks,
Phil

Re: Inpoutx64 and VB.Net 2010

Posted: Thu Mar 10, 2011 10:53 pm
by PaulT
Thanks Phil. I will work on it some more over the weekend.

Re: Inpoutx64 and VB.Net 2010

Posted: Tue Jan 29, 2013 1:46 pm
by sadilza
Hi,


I build a CM in vb .net that works fine in 'interactive' mode.
When running as service the login failed.

Specific the ValidateUser method. It hangs without an error message.
The service is launched with teh same user when running in interactive mode(also administrator from the pc)


User profiles are NOT activated.

Any ideas ?

Re: Inpoutx64 and VB.Net 2010

Posted: Tue Jan 29, 2013 1:51 pm
by phil
Sorry but what has this got to do with InpOut32/x64 or this thread??
Please don't hijack threads or forums for that matter.

Thanks,,
Phil