K8055 dllImport c# Problem

I have been playing with the code and most of it works.

What is really strange is that some of the functions within the K8055D_C.dll work correctly BUT others like WriteAllDigital always breaks in to the debugger with

System.EntryPointNotFoundException
Unable to find an entry point named ‘WriteAllDigital’ in DLL ‘K8055D_C.DLL’

I can connect to the device, I can SETALLDIGITAL and CLEARALLDIGITAL but the rest I always get this error.

I have downloaded the latest DLL’s, I have tried the old ones, the new ones, I have copied the files to the c:\windows\System and c:\windows\system32 and every sub directory of my project. But it appears to make no difference.

Any ideas? It maybe a VS2005 C# feature I am missing, or have misunderstood.

I have even created a managed code DLL and used dllImport in this DLL to be sure that it was not an unmananged code problem, still with no luck.

Thanks

Chris

[quote]System.EntryPointNotFoundException
Unable to find an entry point named ‘WriteAllDigital’ in DLL ‘K8055D_C.DLL’[/quote]

That’s because there is no function ‘WriteAllDigital’ in K8055D_C.dll. If you look at the exports inside the dll, you’ll notice that all of them have name mangling:

So no functions you’d ever have imported would have worked (or even been found), so I don’t understand how any of your functions can work correctly…

It would be better for you to use K8055D.dll which exports all functions without name mangling.

Good luck!

Thank you for the reply,

I completely agree, I was on the assumption (wrongly it would appear) that I required the K8055D_C.dll for C# applications so I used dllImport[“K8055D_C.dll”].

I also don’t understand how this could work for some functions, this is what has caused me to pull a large portion of my hair out, it made no sense.

Name Mangling - Does this render the exports unusable?

Chris

I agree that it’s a bit confusing, i had to take a closer look too :-/

If you really want to use the functions in K8055D_C.dll you just need to use the mangled names:

[DllImport("K8055D_C.dll", EntryPoint = "_CloseDevice@0")]
public static extern void CloseDevice();

Enjoy!

Thanks again

I assume there is some mileage in doing this or is the standard K8055D.dll OK to use? I guess using the new method it is saving a split second hop from 1 dll to the other?

Great little project board though.

Cheers

Chris

I don’t think the dlls use each other :slight_smile: I’m guessing the only reason why there are two dlls is because one is included with a .lib (static linking) for borland C++ builder (different format than microsoft).

Choose whichever one you want, they should be exactly the same. The only difference for you in C# are the exported names. Personally i’d use K8055D.dll for its simplicity.