John Lam 1997 — 2026

Why use C# for this?

Brad Abrams has a pointer to P/Invoke signatures that were created by the C# team. Why anyone would want to use C# for interop is beyond me. In non-trivial cases, there are way too many opportunities to make mistakes while porting C/C++ header files to C# P/Invoke signatures. Since these cases involve structs and/or structs that contain pointers to other structs, you’re ultimately responsible for explicit memory management. You might as well just use Managed C++ and get on with your life :)

2 archived reader comments

Sam Gentile (2004-02-29)

Yup, this is the one case where MC++ makes sense

Valery Pryamikov (2004-02-29)

One obvious use is for programming Compact Framework. C# and P/Invoke is supported there, while as managed C++ is not supported.

-Valery.