Windows Phone 7 和本机 C++/CLI [英] Windows Phone 7 and native C++/CLI

查看:38
本文介绍了Windows Phone 7 和本机 C++/CLI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Microsoft 最近为其新的 Phone 7 平台发布了工具和文档,这让那些拥有庞大 C++ 代码库的人(如我)不再支持本机开发感到沮丧.尽管我发现有关此决定被撤销的猜测,但我对此表示怀疑.所以我在想,通过调整它以在 C++/CLI 下编译,使这个代码库可用于 Phone 7 是多么可行.当然,用户界面部分无法移植,但我不确定其余部分.有没有人有类似的经历?我不是在谈论执行大量低级工作的代码 - 但模板和智能指针的使用非常频繁.

Microsoft recently released tools and documentation for its new Phone 7 platform, which to the dismay of those who have a big C++ codebase (like me) doesn't support native development anymore. Although I've found speculation about this decision being reversed, I doubt it. So I was thinking how viable would be to make this codebase available to Phone 7 by adapting it to compile under C++/CLI. Of course the user interface parts couldn't be ported, but I'm not sure about the rest. Anyone had a similar experience? I'm not talking about code that does heavy low-level stuff - but there's a quite frequent use of templates and smart pointers.

推荐答案

c++/cli 理论上可以与 WPF/Silverlight 一起使用,使用的技巧是将 XAML 生成的 C# 替换为可在 main 中使用的宏定义代码隐藏文件中的类.我制定了这项技术,但没有动力将其超越理论 - 我很高兴混合语言.

c++/cli can theoretically be used with WPF/Silverlight using the trick of replacing the C# generated from the XAML with a macro definition that can be used inside the main class in a code behind file. I worked out this technique but haven't had the motivation to take it beyond theory - I'm quite happy mixing languages.

就在逻辑代码的纯安全模式下使用 c++/cli 而言,这可能仍然不可能,但我很想听听现在有人如何尝试.在 2008 年为 Silverlight 研究它时,我发现这个令人生畏的silverlight 论坛评论:

As far as using c++/cli in a pure safe mode for your logic code, this may still not be possible but I'd love to hear how someone goes trying it now. Whilst researching it for Silverlight back in 2008 I found this daunting silverlight forum comment:

我只是通过将 C++ 项目中的 MSIL 编译成与 Silverlight 兼容的 DLL 来尝试 Silverlight&C++.好消息:它有效,您可以从 Silverlight 项目调用此代码.坏消息:C++ 编译器显然使用了 Silverlight 不允许的 MSIL 指令.

因此,如果您尝试此操作,即使使用最简单的程序,您也几乎会立即收到异常操作可能会破坏运行时的稳定性." 对我来说,这看起来像是我们不太可能很快看到用于 C++ 的 Silverlight,因为编译器的行为需要完全不同.

So, if you try this, even with the simplest of programs, you'll almost immediately get the exception "Operation could destabilize the runtime." To me, this makes it seem less likely that we'll see Silverlight for C++ soon, as the compiler will need to behave quite a bit differently.

这篇关于Windows Phone 7 和本机 C++/CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆