“No such host is known” error for new TcpClient socket connection set up

“No such host is known” error for new TcpClient socket connection set up using .Net Framework classes

I was trying to create a TcpSocket connection to check for .Net’s SSL certificate validation process and was using the TcpClient constructor of the System.Net.Sockets class.

The constructor has a signature like below:

public TcpClient(string hostname, int port)

The hostname is the DNS name of the remote host to which you intend to connect.

The code I wrote and the error was as below.

TcpClient clientFor = new TcpClient(“https://developers.facebook.com”, 443);

image

The funny thing is I put the uri for the host name instead of the DNS name L

The fix was simple:

TcpClient clientFor = new TcpClient(“developers.facebook.com”, 443);

Advertisement

Unable to resolve a reference to Microsoft.CSharp assembly in a .Net project.

In one of my projects I saw that the Microsoft.Csharp reference is not found.

clip_image001

It was strange because for other projects the reference is resolved fine.

Resolution: Somehow my current project framework got pushed to v3.5.

I changed it to v4.0 and that fixed the issue.

It is important that you save the changes before the project framework is changed because the project will re load and you may lose any unsaved work.