Hi there!
The point is that debugging my C# app I faced the error: UriFormatException was unhandled. I've created p2p console chat.
namespace PeerChannelBasic
{
[ServiceContract(
Namespace = "http://slickthought.net/peerchannel",
CallbackContract = typeof(IPeerChannelChat))]
public interface IPeerChannelChat
{
[OperationContract(IsOneWay = true)]
void Logon(string name);
[OperationContract(IsOneWay = true)]
void Chat(string name, string message);
[OperationContract(IsOneWay = true)]
void Logoff(string name);
}
public interface IPeerChannelChatClient : IPeerChannelChat, IClientChannel { }
}
Program.cs :
namespace PeerChannelBasic
{
class Program : IPeerChannelChat
{
static void Main(string[] args)
{
Console.Write("Enter your name: ");
string member = Console.ReadLine();
InstanceContext context = new InstanceContext(new Program());
DuplexChannelFactory<IPeerChannelChatClient> factory = new DuplexChannelFactory<IPeerChannelChatClient>
(context, "ChatChannel");
IPeerChannelChatClient chatClient = factory.CreateChannel();
IOnlineStatus onlineStatus = chatClient.GetProperty<IOnlineStatus>();
onlineStatus.Online += new EventHandler(onlineStatus_Online);
onlineStatus.Offline += new EventHandler(onlineStatus_Offline);
Console.Write("Opening chat client... ");
chatClient.Open();
Console.WriteLine("OPENED");
chatClient.Logon(member);
while (true)
{
Console.Write("Say: ");
string message = Console.ReadLine();
if (message.ToUpper() == "QUIT") break;
chatClient.Chat(member, message);
}
chatClient.Logoff(member);
chatClient.Close();
factory.Close();
}
#region OnlineStatus
static void onlineStatus_Offline(object sender, EventArgs e)
{
Console.WriteLine("<<<- chatClient is OFFLINE");
}
static void onlineStatus_Online(object sender, EventArgs e)
{
Console.WriteLine("<<<- chatClient is ONLINE");
}
#endregion
#region IPeerChannelChat Members
public void Logon(string name)
{
Console.WriteLine("<<<-{0} JOINED", name.ToUpper());
}
public void Chat(string name, string message)
{
Console.WriteLine("{0} SAYS ---> {1}", name.ToUpper(), message);
}
public void Logoff(string name)
{
Console.WriteLine("<<<-{0} EXITED", name.ToUpper());
}
#endregion
}
}
And debugging stops at chatClient.Open() with logs "Invalid URI: The hostname could not be parsed."
By the way, it should be mentioned that this code successfully works in my Windows 7 Home Edition. But in Windows 7 Starter it shows this exception.
Have you got the same experience?
Thanks in advance.