Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It depends what form of sharing you need:</p> <p><strong>1) If you have a common C++ business logic layer</strong> you can use Windows Runtime (WinRT) components to expose this to both Windows Phone and Windows Store app (that's the only use-case for Windows Phone as you can't write a WP8 app using JavaScript or use .NET to author a WinRT component). </p> <p>You'd have to build two separate WinRT components however, one for Phone and one for Windows Store. It should be possible to share the C++/CX code of your WinRT interop layer using preprocessor directives (<code>#if</code>) to mark the platform specific code.</p> <p><strong>2) You have business logic in C#/VB that only has dependencies on the .NET APIs which are available in a Portable Class Library.</strong> Then you can use Portable Class Library (PCL) to contain that logic. Basically if you <em>can</em> build your library into a PCL DLL then this should work. You can then reference this PCL in binary form in both Windows Phone and Windows Store app.</p> <p>However as Martin has said you need to take care when using 3rd party libraries as these will also need to be built for PCL. Some 3rd party libraries are already available in PCL form (JSON.NET for example). </p> <p><strong>3) You want to share code for that has platform API dependencies (or 3rd party library dependencies) which are not supported by PCL.</strong> Then you'd need to create separate DLL libraries, one per platform. You can avoid code duplication using linked C#/VB source files and use a build flag (<code>#if</code> again) to allow small code changes between your target platforms.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload