Win7 home premium 64bit PCANBasicExample error

The free CAN Software API (Application Programming Interface) for Windows®

Win7 home premium 64bit PCANBasicExample error

Postby Rowanp » Mon 7. Mar 2011, 17:07

On moving our set up to a new machine running the above we are now getting InvalidOperationException errors. On further investigation its was found that line 154 errors first. See below. We have the installed PCANBasic.dll 1,0,7,21 in the SysWOW64 dir and PCANBasic.dll 1.0.7.21 (293k) in the system32 dir.
Have run PeakOemDrv.exe as admin. PCAN-View works ok.


Below are the details of the error from Visual Studio 2011

System.InvalidOperationException was unhandled
Message=An error occurred creating the form. See Exception.InnerException for details. The error is: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=PCANBasicExample
StackTrace:
at PCANBasicExample.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
at PCANBasicExample.My.MyProject.MyForms.get_Form1()
at PCANBasicExample.My.MyApplication.OnCreateMainForm() in C:\Users\iPlug\Downloads\PeakCANusb\Disk\PCAN-Basic API\Samples\Visual Basic .Net\My Project\Application.Designer.vb:line 35
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at PCANBasicExample.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
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: System.BadImageFormatException
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=PCANBasicExample
StackTrace:
at PCANBasicExample.Peak.Can.Basic.PCANBasic.GetValue(Byte Channel, TPCANParameter Parameter, UInt32& NumericBuffer, UInt32 BufferLength)
at PCANBasicExample.Form1.btnHwRefresh_Click(Object sender, EventArgs e) in C:\Users\iPlug\Downloads\PeakCANusb\Disk\PCAN-Basic API\Samples\Visual Basic .Net\Form1.vb:line 154
at PCANBasicExample.Form1.FillComboBoxData() in C:\Users\iPlug\Downloads\PeakCANusb\Disk\PCAN-Basic API\Samples\Visual Basic .Net\Form1.vb:line 931
at PCANBasicExample.Form1.InitializeBasicComponents() in C:\Users\iPlug\Downloads\PeakCANusb\Disk\PCAN-Basic API\Samples\Visual Basic .Net\Form1.vb:line 849
at PCANBasicExample.Form1..ctor() in C:\Users\iPlug\Downloads\PeakCANusb\Disk\PCAN-Basic API\Samples\Visual Basic .Net\Form1.vb:line 13
InnerException:
Rowanp
 
Posts: 2
Joined: Mon 7. Mar 2011, 16:41

Re: Win7 home premium 64bit PCANBasicExample error

Postby Rowanp » Mon 7. Mar 2011, 18:06

Just had feed back from the support email address, it appears that the PCANBasic.dll versions are swapped in the Peak zip file directories (Win32 and x64). This was a problem caused by myself going back and forwards in the windows 7 environment my un zipped dir PCANBasic.dll got swapped. Apologies.

I still then had the problem with not picking up the USB CAN port, my orginal code was taken from and older PCANBasic example I found it necessary to change one of the tests:-

From
AndAlso (iBuffer = PCANBasic.PCAN_CHANNEL_UNOCCUPIED)

To
AndAlso (iBuffer = PCANBasic.PCAN_CHANNEL_AVAILABLE)

Hope that helps somebody else trying to migrate to a Visual Studio 2011 express application.
Last edited by Rowanp on Tue 8. Mar 2011, 12:32, edited 1 time in total.
Rowanp
 
Posts: 2
Joined: Mon 7. Mar 2011, 16:41

Re: Win7 home premium 64bit PCANBasicExample error

Postby U.Wilhelm » Tue 8. Mar 2011, 09:29

You have copy the wrong DLLs to the wrong Directories - see our last E-mail from the Support.
:!: The ZIP files are OK and tested - please do not confuse the rest of our customers. :!:

It is very simple:

32bit dlls > Windows\syswow64
64bit dlls > Windows\system32

http://en.wikipedia.org/wiki/WoW64

perhaps you should set your build options in the compiler on x86 only, than on all systems only the 32bit dll will be used.
--------------------------------
PEAK-System Technik
Technical Support Team
support@peak-system.com
-------------------------------
User avatar
U.Wilhelm
Sales & Support
Sales & Support
 
Posts: 247
Joined: Fri 10. Sep 2010, 19:34
Location: Darmstadt


Return to PCAN-Basic



cron