Search code examples
c#character-encodingmarshalling

CharSeT.Ansi does not contain defination for ansi


In C# i am trying to add some additional info like

[DllImport("\\SD Card\\ISAPI1.dll", CharSet = CharSet.Ansi)]

but build process giving error

Error   1   'System.Runtime.InteropServices.CharSet' does not contain a definition for 'Ansi'   

and the same error "does not contain a defination" i am receiving with

Marshal.PtrToStringAnsi(intPtr);

i am creating a c# application for WinCE 6.0


Solution

  • The compact framework does not support ANSI at all. Hence those parts of the framework relating to ANSI do not exist.

    You should use Unicode on the compact framework. I mean, you should use Unicode everywhere, but you get no choice on compact!