markmnl
markmnl

Reputation: 11426

Can I write a library for Windows store apps that uses sockets and is not a "Windows store app library"?

I am writing a library that uses UDP sockets to be used by Windows store apps.

Can a Windows store app reference a native library that directly uses Winsock?

Can a Windows store app reference a CLR library written for .Net 4.5 that uses Sockets in System.Net.

Or do I have to write the library as a Windows store app library and use Windows.Networking.Sockets API?

(I suspect I know the answer am just making sure.)

Upvotes: 1

Views: 1162

Answers (2)

Hans Passant
Hans Passant

Reputation: 941465

Can a Windows store app reference a native library that directly uses Winsock?

No, the Store validator will reject any program that tries to use a Winsock function.

Can a Windows store app reference a CLR library written for .Net 4.5 that uses Sockets in System.Net.

You cannot write such a library. Selecting the .NETCore profile (PCL or Store app) prevents using the System.Net.Socket class. It is simply missing and will generate a compile error.

Using the WinRT Windows.Networking.Sockets.DatagramSocket type is required to get UDP going in a Store app. This type is compatible with the Store app sandbox that enforces the requested network capability in the application's manifest.

Upvotes: 2

Ross Dargan
Ross Dargan

Reputation: 6021

I have done something similar, but ultimately the answer is no.

You basically use a portable class library for the bulk of the work, and abstract out any socket based work. You then create an implementation of the abstraction in both the class library, and the windows store class library.

This works nicely, and I'd highly recommend this, but I'm afraid to answer your question no you can't.

Upvotes: 1

Related Questions