pinvoke

C++ DLL causes error when specific method called from .NET wrapper

I have this C++ dll where i created a wrapper with PInvoker. This small app is working great on my development pc with windows 7 64 bit. But soon as i try to work the release on a xp machine and when a specific action is happening it throws an error that the device is not ready. The dll is managing a serial device, where in all other act...

P/Invoke C# to C++

Hi, I'm trying to learn how to run C# and C++ code together using Mono on RedHat. I'm fooling around in order to learn how to get the two to interoperate together in order to be a bit more educated when I work on a larger project. I've got a problem that I'm making a P/Invoke call from the C# to my C++ code and an exception is being th...

What is the correct way to set StringBuilder.Capacity when using P/Invoke?

Should StringBuilder.Capacity be set to the maximum number of .NET characters, without regards to null termination, or must it be set one higher to reserve space for a null terminator when using P/Invoke. The natural reaction is that it should be set one higher, but it seems like P/Invoke is supposed to automatically compensate. In fact...