469,946 Members | 1,771 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

How to call a function in a Delphi DLL from C# - PChar as parameter

I have a Delphi DLL function:
function GetMyNickName(aMyName: PChar): PChar; stdcall;

This will return my nickname.

In ASP.NET, C#:
[DllImport("TestDLL.dll", EntryPoint = "GetMyNickName",
ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
static extern string GetMyNickName(string aMyName);


In the button on click event:

string myName;
string myNickName;

myName = "John Smith";
myNickName = GetMyNickName(myName);
Response.Write(myNickName);

I got a runtime error:
A call to PInvoke function 'App_Web_ojpwdprl!Default2::GetMyNickName' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

Anyone has idea?

Thanks
Jul 2 '10 #1
0 1403

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Adam Dyga | last post: by
3 posts views Thread by xuatla | last post: by
6 posts views Thread by M B HONG 20 | last post: by
5 posts views Thread by Lucy Randles | last post: by
3 posts views Thread by Andrew | last post: by
4 posts views Thread by Dave | last post: by
12 posts views Thread by leaf | last post: by
3 posts views Thread by thomas | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.