PInvoke C# web service char*

B

bsma1

I'm writing a web service that makes calls into a C DLL. I've been
able to make most of the calls work except for one that returns a
string via a char* passed in as a parameter. Here's what I have:

The C function looks like this:
uint func1(char*, uint)

My C# code on the server is this:
[DllImport("mydll.dll", SetLastError = true)]
static extern unsafe uint func1([MarshalAs(UnmanagedType.LPStr)]out
string errStr, uint errorCode);

[WebMethod]
public unsafe uint callFunc1(uint errorCode, out string errorString)
{
return func1(out errorString, errorCode);
}

My C# code on the client (consumer) looks like this:
protected void myClientFunc(uint code)
{
string errorString;
proxy.func1(code, errorString);
}

When I run this I get a "Client found response content type of 'text/
html; charset=utf-8', but expected 'text/xml'." Any help is greatly
appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top