C# Drivers Motion Control Drivers

163 views
Skip to first unread message

VelmexControls

unread,
Jan 23, 2014, 9:20:26 AM1/23/14
to velmex-...@googlegroups.com
Administrator Note: The below is what James has posted a few times and for some reason is not posting to the group?

Hello, Sorry for the repeat post, my last one might have gotten lost. I tried running the Velmex example C# code to operate a linear translation stage, using Microsoft Visual C# Studio 2010 express. The code compiles OK, but does not seem to do anything to the translation stage. The same hardware operates fine using a labview driver, but I need to operate in the C# environment for my next task. Cliff at Velmex gave me some diligent support over the phone and a webex, but we couldn't get it working. James
vxm_example_c_sharp2003.zip

VelmexControls

unread,
Jan 23, 2014, 9:27:19 AM1/23/14
to velmex-...@googlegroups.com
Update:

I do not know enough about C# and the original code was from 2003 and should still be working today.
However debugging my way through, I find that "LoadLibrary" is returning 0 indicating that it can not find the Dll
I have tried changing the path to use the full path to the DLL and it still returns 0

Unfortunately I can not seem to properly be able to add the "GetLastError" and "FormatMessage" from the Windows API to tell me why "LoadLibrary" would not be able to load the DLL when the function is part of the Windows Operating System?

Cliff

VelmexControls

unread,
Feb 1, 2014, 12:56:04 PM2/1/14
to velmex-...@googlegroups.com

I did a fresh install of Visual C# express edition and tried some solutions that I saw online based on my hunch that at some point in the past
M$ changed how the "Express" languages compile to 64bit now instead of the default of 32bits.
Following hints from "Change target CPU settings" I did the following:
1.) Go to "Tools--->Options"
2.) Make sure the "Show all options" checkbox is checked
3.) Select the "Projects and solutions"
4.) Ensure the "Show Advanced build configurations" checkbox is checked
5.) Click the "OK" button

Once that is done, then perform the following:
1.) Goto "Tools--->Settings"
2.) Ensure the "Expert Settings" is selected

At this point you should now see a menu option for "Build" (between "Project" and "Debug"
Make sure that you are not currently debugging and select the "Build--->Configuration Manager" menu
then perform the following:
1.) Drop down the "Active Solution Platform"
2.) Select "New"
3.) Drop down the "Select the new platform" and select "x86"
4.) Ensure the dropdown for "Copy settings from" is selected for "Any CPU"
5.) Click "OK"

Now try debugging again and ensure that the "hLib" variable in the "LoadDriver" function now has a value other than zero
If it does then the example for using the "VxmDriver" should now be working.

I will try to work up a tutorial for future reference if I see this problem happen again.

Cliff

ohallor...@gmail.com

unread,
Aug 12, 2015, 8:04:23 AM8/12/15
to Velmex Controls

Hey I am having this same problem and I am using the newest Visual Studio Express. I have tried your fix, but it does not seem to work. Do you have any more suggestions?

Cliff

unread,
Aug 12, 2015, 10:56:52 AM8/12/15
to Velmex Controls, ohallor...@gmail.com
What version of Windows are you using?
Reply all
Reply to author
Forward
0 new messages