2

I'm working on a personal project with VS 2015/Universal app solution and i try to follow this code sample :

Asynchronous Server Socket Example

But when i want to create a new IPHostEntry or make a Dns.GetHostName() VS don't find the assembly.

I have these references on my solution explorer :

Analyzer
Microsoft.ApplicationInsights
Microsoft.ApplicationInsights.PersistenceChannel
Microsoft.ApplicationInsights.WindowsApps
Microsoft.NETCore.UniversalWindowsPlatform
Universal Windows

and the using directives following :

using System; 
using System.Collections.Generic; 
using System.Collections.ObjectModel; 
using System.Diagnostics; 
using System.IO; 
using System.Linq; 
using System.Net; 
using System.Text;
using System.Threading.Tasks; 
using System.Xml; 
using System.Xml.Serialization; 
using System.Net.Sockets;

I tried also to add System.Net dll manually (located in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6) to the solution references but i got an error telling me that the component is already automatically added by the generation system.

yms
  • 10,361
  • 3
  • 38
  • 68
Nimp
  • 441
  • 1
  • 5
  • 15
  • Did you use .NETFramework 4.5/4.6 as a target framework? – Roman Marusyk Nov 09 '15 at 16:03
  • Thanks for the answer but I cant target a specific framework in the options of my solution, i have just " target : Universal Windows" with no choices – Nimp Nov 09 '15 at 16:09
  • Sorry? I guess you did not understand me correctly. I mean what target framework you use in Properties -> Application in your project([link](https://i-msdn.sec.s-msft.com/dynimg/IC712091.jpeg))? And it was not an answer, it was a question – Roman Marusyk Nov 09 '15 at 16:14
  • thanks again, i have understand what you mean i think, i want to show you by a screenshot but i dont know if i have the right, you can see here : http://hpics.li/9b1fa97 so i have not a lot of choices as you can see, and there is no other choices for target version/min version – Nimp Nov 09 '15 at 16:23
  • Ok, did you try to remove System.Net and added it again? – Roman Marusyk Nov 09 '15 at 22:18
  • I cant remove System.net from the references cause its not a reference... i should miss something... – Nimp Nov 10 '15 at 11:41

1 Answers1

2

Windows Store Apps use a different version of .Net framework, which does not contain many of the classes of the "regular" .Net framework, the functionality for some of the missing classes might be offered under a different namespace and type.

Take a look at these pages for more details:

.NET for Windows Store apps overview

System.Net namespaces for UWP apps

It seems to me that the interfaces and methods you are trying to use are not available.

Edit from comments: There is a StreamSocket sample for UWP in MSDN

yms
  • 10,361
  • 3
  • 38
  • 68
  • thanks for the answer, i will just add for complete the thread this answer from [MSDN](https://social.msdn.microsoft.com/Forums/fr-FR/7a8e6e6d-55fe-46fb-8344-07692132144c/uwp-cant-find-classadd-net-reference-universal-windows?forum=wpdevelop) who contain a link to a UWP socket sample. – Nimp Nov 12 '15 at 15:29