|
Cannot implicitly convert type 'object' to 'System.ServiceModel.PeerNodeAddress'.An explicit conversion exists (are you missing a cast?) Greetings,
I have built a WCF client with a custom peer resolver as a chat
application. The code for both applications (client and server) work
fine, and I am able to resolve clients through the Resolver Contract;
HOWEVER, I am not sure what to pass to register the clients using the
Regeister method with parameters "MeshId" and "PeerNodeAddress".
In my research I know the the PeerNodeAddress is encapsulated in a
seal class PeerNodeAddress. I have searched the Internet for an
example of what the PeerNodeAddress would look like as a passed
parameter, but there is nothing out there.
My question:
When I call the Register method to register my client with the server
what am I passing? Am I passing the IP Address of the client? If so,
how would I cast the IPAddress type into a PeerNodeAddress? Does
anyone have a working example?
Here is the error message I get when I try to assign the client IP
address:
<code>
PeerNodeAddress nodeAddress;
IPHostEntry ips = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress address in ips.AddressList)
{
if (address.AddressFamily ==
System.Net.Sockets.AddressFamily.InterNetwork)
nodeAddress = address as PeerNodeAddress;
}
<error>
Cannot implicitly convert type 'object' to
'System.ServiceModel.PeerNodeAddress'. An explicit conversion exists
(are you missing a cast?)
Question, what is the correct cast? |