Import C++ DLL in C# Servo Motor - c#

I'm trying to make a Servo Motor work with very simple code in C#. The company that built the Servo is called TEKNIC, and the motor that I'm trying to move is the ClearPath-SC-Series.
That company offers a software download called ClearView and contains a lot of sample code to be used in C++, also, they create a DLL file with a ton of Classes, Methods, Codes and so on, that you can use to import into your own code. However, these DLL was built in C++ as well.
Om my C# application I'm trying to use P/Invoke to access that DLL but without success. Can someone please help me? I am using System.Runtime.InteropServices
Here is where I'm calling the DLL
[DllImport("C:\\Program Files(x86)\\Teknic\\ClearView\\sdk\\lib\\win\\Release\\x64\\MNuserDriver20.dll", EntryPoint = "SysManager")]
I'm not sure what would be the next steps
Link for Teknic Software

I'm an applications engineer with Teknic and I came across your post. I know this is a few months late, but I wanted to respond in case you or others still have questions about this.
Teknic now includes C# example projects included in the sdk installed with the ClearView software.
The ClearView software is a free download from Teknic's website(https://www.teknic.com/downloads/). The C # examples are installed to this file location: C:\Program Files (x86)\Teknic\ClearView\sdk\CSharp Examples
These examples were built and tested with Microsoft Visual Studio 2015, which is a free download(https://www.visualstudio.com/vs/older-downloads/). Using other versions of Visual Studio may cause the projects to load incorrectly, so we recommend using the 2015 version.
For any technical questions regarding these examples, please email us at support#teknic.com
Thank you,
Brendan

Related

Setting up a mixed C# and C++ project in Visual Studio

I want to create a Windows application using a C# GUI that calls some C++ code but I have troubles setting up the project in Visual Studio.
I understood that I have to do it the following way : 3 projects (the C++ project, the C# project and a wrapper CLR project) that are linked to each others in some way. I just can't figure out how the link works.
If anyone can explain me in details what I have to do, I'd be really happy :3
Otherwise, I can use a Github link of a project already set up that I could copy.
Thanks in advance to anyone who will take some time to answer.

Working with Cocos 2d-x inside of Microsoft Visual Studios Community 2015

To start things off i am an amateur programmer and have basically only used visual studios to make anything i have made in school. C# is what i am familiar with as far as game development goes, and at this point i am trying to develop a game using visual studios & cocos2ds. That i can somehow port over to the Apple App Store.(Stop me if any of this is completely impossible, like i said i am quite new to the whole app development thing)
So I have one Big question that kind of stems off into a few others. Most importantly I currently have Microsoft Visual Studios Community 2015 version, and I would like to use Cocos 2d-x in unison with VS to create an app. I have currently sifted through a lot of different websites and eventually stumbled upon this : https://www.youtube.com/watch?v=xqtT0E68TJM. This guy is the most informative resource i have found for installing Cocos with VS. I followed his entire tutorial to the very end. With a few minor changes.
At the very end of the tutorial you can see he opens the project.sln file in Visual Studios and runs it. This then brings up the little interface with some numbers across the bottom. When i open it in my Visual Studios it says :
"Unable to start program"
C:\Users\guy\Desktop\Personal\Projects\GameTest1\GameTest1\proj.win32\Debug.win32\GameTest1.exe
The system cannot find file specified."
I cant figure out What exactly is going wrong and why mine wont work. Like i said i only changed a few things from the tutorial but that was because it was from years ago, So i had VS 2015 instead of 13 etc. But my changes were as follows:
I updated my Java recently which was up to Java 8. I downloaded the Newest Eclipse from their website and ran it just like in the tutorial ^. But it didn't work so i had to figure out that in order to run .py files like in the tutorial you had to add "python " before the "cocos.py new ......" in order to create a new file. Then it told me that i had to be running Java 1.6 Whilst i was currently running 1.8. So i downloaded an earlier build of Java then used it as the path destination for eclipse. Then aside from that everything built and i ended up with the right files named correctly in the right spot and presumably in the right format. It just gave me that error ^ at the very last step of the tutorial :S.
Firstly - Cocos2d-x uses C++ or Js(i.e. Cocos2d-js) and not C#.
Secondly - Yes you can port your app to apple app store with Cocos2d-x but it can only be done by a mac but not a windows pc .So if you want to port your game to apple devices you must be having a mac.
Thirdly - It doesn't matter if you have installed java unless you are developing for android.If you want to port your game to android then you must have java installed(it doesn't matter if you have latest version or not but you should install greater than v1.5)
Now coming to your problem
Ensure that you have python version2.7 or greater is installed version 3. will not work.
Also ensure that you don't have any spaces in your file path as that may cause error sometimes.
Hope it helps
Lovekesh Garg provided me with a complete, if not incredibly extensive (abundantly helpful) explanation of basically everything i have asked.
I have been pursuing other interest after realizing the expense involved after some investigation so i apologize for the late answer posting :S.

How do I find the source of a "A procedure imported by 'xxx.dll' could not be loaded." exception?

I have been chasing this exception for the past week.
Situation is:
I have an application that is written in C# and built in Visual Studio 2010.
The application includes a DLL that is a wrapper of an unmanaged code library.
The unmanaged code is written in C++ and built in Visual Studio 2008. This is required because the code references additional libraries (Qt) and that code targets WinCE version 5 (necessary due to devices supported in the field).
I have tried many of the suggestions I have seen here, including using various dependency walkers (VS 2008 depends, dependency_walker, and Dependz) as well as other tools such as Reflector and Process Monitor from SysInternals.
All of the tools either show no problems (Reflector) or old dependencies that are obsolete in my environment (Win 7) like DCOMP.DLL, GPSVC.DLL, & IESHIMS.DLL.
In the debugger, I can step through my code right up until I instantiate an object that references my Managed Wrapper DLL. It does not step into the instantiation of the object, but throws the exception immediately.
In Process Explorer (from SysInternals) I can see the Managed DLL loaded, along with the necessary subsidiary DLLs. In Process Monitor (from SysInternals) at the point of the problem there are no stacks of not found messages. It just fails.
Any ideas or thoughts in finding this problem would be appreciated.
# Hans Passat - Thank you for the hint on Global Flags.
Here is an excellent blog post on using the tools. The gflags.exe program referred to by most of the Google references to "Show Loader Stacks" is part of the Windows Device Driver Development Kit (WinDDK) and it manages the Registry settings mentioned in that post for you.
The output from running with "Show Loader Stacks" identified that a symbol that should have been in my unmanaged DLL was not in the DLL I was using.
It turns out that I was building the wrong version of the DLL. This was due to my poor understanding of the build process (too many versions built too many different ways).
Standard tool for the job: Dependency Walker

dll built on vs2005 differently on different machines

I'm building a dll(c# assembly which implements some interfaces) that's called by another app. the dll built on my machine works but the one built on our build machine does not work. I have very little control on that app and can not debug it, I can only see the output of it. Is there any way to check the differences of the dlls? I have used reflector, but it only shows limited info like classes and methods.
I also tried building it on other machines with vs2005, xps can create correctly, server 2008 and win7 can not.
could you guys help me with it? any help would be appreciated. If I was not clear, please let me know.
Thank you!
Since you didn-t tell us the error-symptoms of "does not work" here is my guess formulated as a question:
Does your dll reference other dlls that are installed in global-assembly-cache? do all build machines have the same version of the gac-dll installed?

LuaInterface and 64Bit

Ok i'm currently using LuaScript v5.1 in a Game engine i'm using. and the handy LuaInterface that comes along with it. i've tested it on a range of systems running a range of OS's.
LuaInterface seems to fail on 64bit Operating Systems.
Could anyone point me to a 64bit Compiled LuaInterface.dll, or is there any alternative to the LuaInterface that can be used, because LuaInterface is extremely useful and i dont think i would be able to write a more extensive interface by myself using lua51. (I'm not that good, sadly)
Any help or links would be greatly appreciated.
Thanks alot guys!
You can check out the LuaInterface source code from the Subversion repository hosted on Google Code. It contains Visual Studio project files for building it yourself. Welcome to the world of open-source software!
I just found some links that might help with your problem.
This shows how to modify compiled assemblies to force them to run 32 bit:
http://bchavez.bitarmory.com/archive/2008/04/29/badimageformatexception-errors.aspx
This shows how to compile to target 32 bit:
http://www.atalasoft.com/kb/article.aspx?id=10165
Read this article for a good understanding of 32 and 64 bit managed apps:
http://blogs.msdn.com/joshwil/archive/2004/03/11/88280.aspx
Another good link that talks about 32 vs 64 bit:
http://www.hanselman.com/blog/BackToBasics32bitAnd64bitConfusionAroundX86AndX64AndTheNETFrameworkAndCLR.aspx
You can use KopiLuaInterface. I uses KopiLua, which is written entirely in C# and provides all the well-known interfaces like LuaInterfaces. It even implements the same namespaces as LuaInterface, so you don't have to change anything except your references!
I just migrated my project from LuaInterface to KopiLuaInterface in under 10 minutes without changing a single line of code!
You can find KopiLuaInterface here: https://github.com/gfoot/kopiluainterface/releases
Just remove your LuaInterface and lua51 DLL files from your project and add the 3 DLLs from the KopiLuaInterface release, update your references and you're done.
NLua supports 64 bits and is available via NuGet.
NLua site : http://nlua.org
GitHub: https://github.com/nlua/nlua
NuGet: https://www.nuget.org/packages/NLua/

Categories

Resources