Reputation: 381
I am working on a project which targets windows 8.1 (windows store app) and windows phone 8. A library is required that creates and receives TCP/UDP packets.
I have a piece of code that works on each, WP8 and Windows 8.1 (using the exact same code). However when I want to put this code in a portable class library suddenly certain using directives are not recognized any more:
using Windows.Networking;
using Windows.Networking.Connectivity;
using Windows.Networking.Sockets;
I understand that PCLs only have the featureset that overlaps between the frameworks however as these directives work in a Windows 8.1 class library and also in a WP8 library I was under the impression that I should be able to create a PCL out of it.
Where am I mistaken? If there is really no way to combine these into a PCL how can I approach this issue without keeping/maintaining duplicate code for each target?
Upvotes: 1
Views: 1342
Reputation: 16744
Those are WinRT APIs, which PCLs don't currently support. You can vote for this feature here: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/4443287-make-winrt-api-usable-in-portable-class-libraries-
Your main options right now are to forgo PCLs, or to create a portable abstraction for this functionality and an implementation for each platform (in this case the code for each platform would be the same and could be shared via linked files).
Upvotes: 2