Your function signature in the second case looks wrong as far as I guess from the two different languages.

Your DLL annotation looks like it says that the C type of the argument should be LPWStr, but your C++ functon signature uses std::string.

But in your first case you also have "int" as the return type while the C# function has string.
The variable names make even less sense to me, usually "ptr" indicates a pointer, but an int wouldn't be capable of holding a pointer.

Maybe Microsoft's developer documentation has some examples on how to call a C# DLL function from C?

Cheers,
_