C# program can't find DLL

Post questions and issues with Concept2 PM3 SDK

C# program can't find DLL

Postby Blobbies » April 4th, 2017, 3:51 am

I'm trying to connect a PM4 to my computer with a C# program to get some parameters like velocity and such.
The problem is that I get a error that the DLL cannot be found.
I'm using a code from the internet https://micrological.appspot.com/article/content.projects.erg.

At the end of PM3.cs the files RPPM3DDI.dll and RPPM3Csafe.dll are imported with the help of DllImport.
These files are replaced with PM3DDICP.dll and PM3CsafeCP.dll.
This is the code:

Code: Select all
        [DllImport("PM3DDICP.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern ushort tkcmdsetDDI_init();

        [DllImport("PM3DDICP.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern ushort tkcmdsetDDI_discover_pm3s(
           string product_name,
           ushort starting_address,
           ref ushort num_units);

        [DllImport("PM3CsafeCP.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern ushort tkcmdsetCSAFE_init_protocol(ushort timeout);

        [DllImport("PM3CsafeCP.dll", CallingConvention = CallingConvention.Cdecl)]
        public static extern ushort tkcmdsetCSAFE_command(
           ushort unit_address,
           ushort cmd_data_size,
           uint[] cmd_data,
           ref ushort rsp_data_size,
           uint[] rsp_data);


If I run the program I get the exception: An unhandled exception of type 'System.DllNotFoundException' occurred

I was wondering (and hoping) someone might be able to help me with this problem...
Blobbies
Paddler
 
Posts: 1
Joined: April 4th, 2017, 3:22 am

Re: C# program can't find DLL

Postby TheRocketeer » June 3rd, 2017, 8:34 pm

The system has to be able to find the DLLs. Do you have them in the same directory as the executable? That's the easiest way to help the system find them.
"You can't outrun a donut." -- TomR
TheRocketeer
500m Poster
 
Posts: 99
Joined: January 23rd, 2013, 10:44 pm


Return to SDK Questions

Who is online

Users browsing this forum: No registered users and 2 guests