-2

I want to call native C++ code from a windows phone 8.1 project. I was going off this How do I call C++/CLI from C#? for a while up until I found out that I can't reference a C++/CLI library in my windows phone project... too bad, because that would've been very convenient.

How ought I go about this?

Community
  • 1
  • 1
MNagy
  • 423
  • 7
  • 20
  • You will need to rebuild your C++ code to target WinRT: https://msdn.microsoft.com/en-us/library/mt186162.aspx so it's compiled to a WinMD library which can then be called from C#. – Dai Jan 31 '17 at 00:07

1 Answers1

1

You can also use Platform Invoke. It's much lighter weight, but you should be pretty comfortable about translating the definitions in the header files to .NET types. And don't even bother trying straight C++--it's doable but really messy. Wrap it in a C API and dynamically bind that.

https://msdn.microsoft.com/en-us/library/26thfadc(v=vs.110).aspx

Jonathan Henson
  • 8,076
  • 3
  • 28
  • 52