locked
Windows Store C# app implementing unique C++ code per CPU architecture

    Question

  • I need to implement a Windows Store C# app that implements unique C++ code per CPU architecture.  Ideally I end up with a single executable that works on all architectures.

    How do I do this in the Universal App paradigm?

    Thanks

    Friday, November 21, 2014 10:35 PM

Answers

  • Universal projects are about sharing source not sharing binaries.

    You cannot use the same native (C++) DLL on both x86 and ARM.

    Even at the source level it's not 100%. Chuck's posts are about how to manage the differences. His blog entries pre-date universal projects, but for the most part what he says about Windows Store now applies to Windows Phone Store apps too.

    • Marked as answer by lil'sprout Saturday, November 22, 2014 12:53 AM
    Saturday, November 22, 2014 12:32 AM
    Owner

All replies

  • You cannot. C++ generates architecture specific native code. There is no AnyCPU option for C++.

    You will need to generate and publish separate app packages (Windows ARM, Windows x86, Windows Phone ARM. Windows x86 will run on x64). Users will automatically download the best available match for the system they are installing on.

    Friday, November 21, 2014 10:46 PM
    Owner
  • I was thinking the C++ would be implemented in a Universal C++ DLL, adding each DLL to the AppX manifest.  The C# code would load DLL based on the host CPU architecture.

    Could this be made to work in a Universal App, or am I stuck with the one to one scenario?

    Thanks!

    Friday, November 21, 2014 11:08 PM
  • That's a bit different. It would in theory work for a side-loaded app, but I suspect it would fail certification.

    Why do you want to do this? It sounds more complicated and less efficient than separate packages since you'd be including a lot of dead code.

    Why do you want to ship a phone DLL to a Windows device or an x86 DLL to a phone?

    Friday, November 21, 2014 11:28 PM
    Owner
  • Motivation is primarily to better deal with internal distribution, control, and usage.  I think for cert I would simply have single DLL defined in AppX manifest.

    Any other relevant info beyond these two blog posts?  The target application is SOC benchmarking...

    http://blogs.msdn.com/b/chuckw/archive/2012/09/17/dual-use-coding-techniques-for-games.aspx
    http://blogs.msdn.com/b/chuckw/archive/2012/09/18/dual-use-coding-techniques-for-games-part-2.aspx

    These don't reference using a Universal DLL.

    Thanks!

    Saturday, November 22, 2014 12:21 AM
  • Universal projects are about sharing source not sharing binaries.

    You cannot use the same native (C++) DLL on both x86 and ARM.

    Even at the source level it's not 100%. Chuck's posts are about how to manage the differences. His blog entries pre-date universal projects, but for the most part what he says about Windows Store now applies to Windows Phone Store apps too.

    • Marked as answer by lil'sprout Saturday, November 22, 2014 12:53 AM
    Saturday, November 22, 2014 12:32 AM
    Owner
  • Thanks for your input!
    Saturday, November 22, 2014 12:53 AM