简体   繁体   English

我们可以在Windows Phone 8的XAML中编写或调用“ C代码”吗?

[英]Can we write or call “C code” in XAML for Windows Phone 8

Can we write or call "C code" in XAML for Windows Phone 8, 我们可以在Windows Phone 8的XAML中编写或调用“ C代码”吗?

i'm having C library and i have to use it in WP8 application. 我有C库,必须在WP8应用程序中使用它。 any idea.. 任何想法..

Yes you can - but you have to link it against a C++ project. 是的,您可以-但是您必须将其链接到C ++项目。 What you need is a WinRT component that links against that library and acts as a wrapper. 您需要一个WinRT组件,该组件链接到该库并充当包装器。 That component can then be used in C#. 然后可以在C#中使用该组件。

Check out MSDN docs . 查看MSDN文档

Windows Phone doesn't support P/Invoke so, no. Windows Phone不支持P / Invoke,所以不。 You can't. 你不能 Especially if you want your app to be approved for the App Store: 特别是如果您希望您的应用程序被批准用于App Store:

4.2.2 4.2.2

For Windows Phone OS 7.1 Apps that target Windows Phone OS 7.1 must not invoke native code APIs by using PInvoke or COM interoperability. 对于Windows Phone OS 7.1,面向Windows Phone OS 7.1的应用程序不得通过使用PInvoke或COM互操作性来调用本机代码API。

For Windows Phone 8 Apps that target Windows Phone 8 must not invoke native code APIs other than the APIs listed at Win32 and COM API for Windows Phone 8. 对于Windows Phone 8,面向Windows Phone 8的应用程序不得调用Win32和Windows Phone 8的COM API中列出的API以外的本机代码API。

Remember, your C library is probably pre-compiled for x86 which means that you would have to re-compile the source for different devices. 请记住,您的C库可能已经针对x86进行了预编译,这意味着您必须为不同的设备重新编译源代码。

Your best bet is to check out the C source and see how difficult it would be to port to C#. 最好的选择是检查C源代码,看看移植到C#有多困难。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM