سؤال

I'm using a game engine which generates a native C++ project (DirectX) for a Windows Phone 8 app. To integrate such things as in-app-billing however I need to call a C# method everytime a specific C++ method is triggered in the engine. There is a SO-thread named calling a C# method from C++ in WP8 which apparently is just the other way around: "a C# based app actually calling a C++ method".

Where I'm stuck right now is that I created a "Visual C++ -> Windows Phone Runtime Component" with a C++/CX public ref class sealed using Visual Studio 2012 Express for Windows Phone. This references a .winmd file of a "Visual C# -> Windows Store Class Library" that has the project properties set to "Windows Runtime Component". Interestingly I had to create this in Visual Studio 2012 Express for Windows 8 (NOT Windows Phone), because VS for WP8 doesnt provide an option for generating a .winmd file. Compiling my game I get the following error message:

No implementation file was provided for the .winmd file '...\InAppBilling.winmd'. To enable generation of registration information in the app manifest, specify the 'Implementation' metadata on the winmd reference item in the project file.

How do I call a C# method from within C++? I don't need any fancy stuff like DLLs, inheritance, delegates etc. Just a plain static call that works, everything else will be handled in C# anyway.

هل كانت مفيدة؟

المحلول

This is only possible if you create a XAML and Direct3D app. In that case you can call from C++ to C# using the Windows Runtime method in the other SO question.

As it is not possible to create a C# Windows Runtime component on the phone (unlike for a Windows Store app), it isn't possible to call a C# method from a native C++ project.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top