On Windows CE 5.0 and CF2.0 a try to send a string from a unmanaged DLL to
managed app:

extern "C" __declspec(dllexport) void GetError(char *pErrorMessage)
{
strcpy(pErrorMessage, "Hello C# World!");
}



[DllImport("TestDll.dll")]
internal static extern void GetError([MarshalAs(UnmanagedType.LPStr)]
StringBuilder errorMessage);

StringBuilder message = new StringBuilder(500);
GetError(message );

I allways get an error 'NotSupportedException'.

Thanks for help!
Markus

Re: String from unmanaged DLL to managed app by ctacke/>

ctacke/>
Wed Nov 23 06:27:54 CST 2005

CE is Unicode, so change that to use Unicode strings..

extern "C" __declspec(dllexport) void GetError(TCHAR *pErrorMessage)
{
_tcscpy(pErrorMessage, _T("Hello C# World!"));
}

-Chris


"Markus Forrer" <markus_5@gmx.net> wrote in message
news:Oxj7NsB8FHA.2364@TK2MSFTNGP12.phx.gbl...
> On Windows CE 5.0 and CF2.0 a try to send a string from a unmanaged DLL to
> managed app:
>
> extern "C" __declspec(dllexport) void GetError(char *pErrorMessage)
> {
> strcpy(pErrorMessage, "Hello C# World!");
> }
>
>
>
> [DllImport("TestDll.dll")]
> internal static extern void GetError([MarshalAs(UnmanagedType.LPStr)]
> StringBuilder errorMessage);
>
> StringBuilder message = new StringBuilder(500);
> GetError(message );
>
> I allways get an error 'NotSupportedException'.
>
> Thanks for help!
> Markus
>



Re: String from unmanaged DLL to managed app by Markus

Markus
Wed Nov 23 06:44:50 CST 2005

> CE is Unicode, so change that to use Unicode strings..

...and I also had to remove 'MarshalAs'! Now it works, thank you very much!
Markus