Hi,
I just try MF WCF sample on my card, but it always pops out below error message. I even comment out all code except the Device. Initialize() and Device.Start(), no any change to code, it still can’t work.
Pls help, thx.
I run another sample with socket, with same IP address, it can work.
I also read Device.IPv4Address = "192.168.1.101"
So what’s this mean can’t assign address, how can I solve it?
Yes, I saw that post, but it also had no solution, so I posted here for help.
And below is the code from .Net Micro Framework sample, I just comment out hosted service for confirming the problem is wcf server itself .
public void Start()
{
// Initialize the binding
//Guid g = Guid.NewGuid();
string guid = "urn:uuid:18571766-87df-06e2-bb68-5136c48f483f";
// ProtocolVersion10 can be used only if the corresponding HelloWorldClient_WCF application
// uses a custom binding with Soap12WSAddressingAugust2004 text message encoding.
ProtocolVersion version = new ProtocolVersion11();
WS2007HttpBinding binding = new WS2007HttpBinding(new HttpTransportBindingConfig(guid, 8084));
// maybe due to this returns empty:WsNetworkServices.GetLocalIPV4Address()
string uri = binding.Transport.EndpointAddress.AbsoluteUri;
Device.Initialize(binding, version);
//Device.Initialize(new WS2007HttpBinding(new HttpTransportBindingConfig(new System.Uri("http://192.168.1.101:8084", UriKind.Absolute))), version);
// Set device information
//Device.ThisModel.Manufacturer = "GHI Electronics";
//Device.ThisModel.ManufacturerUrl = "http://www.GHI Electronics.com/";
//Device.ThisModel.ModelName = "Chipworks MINI9261I";
//Device.ThisModel.ModelNumber = "1.4";
//Device.ThisModel.ModelUrl = "http://www.GHI Electronics.com/";
//Device.ThisModel.PresentationUrl = "http://www.GHI Electronics.com/";
//Device.ThisDevice.FriendlyName = "HelloWorldService";
//Device.ThisDevice.FirmwareVersion = "4.1.7.0";
//Device.ThisDevice.SerialNumber = "32345678";
string ip = Device.IPV4Address;
// Add a Host service type
//Device.Host = new HelloWCFService(version);
// Add Dpws hosted service(s) to the device
//Device.HostedServices.Add(new IServiceHelloWCF(new wcfTestImplement()));
// Set this device property if you want to ignore this clients request
Device.IgnoreLocalClientRequest = true;
// Turn console messages on
Console.Verbose = true;
System.Ext.Console.Write("Start DPWS device service with endpoint address: '" + Device.EndpointAddress + "'");
ServerBindingContext ctx = new ServerBindingContext(version);
try
{
// Start the device
Device.Start(ctx);
}
catch (Exception e)
{
System.Ext.Console.Write(e.ToString());
throw;
}
}
When I used your code like that I got the same exception. I added a few lines to initialize the network first… although this is hardcoded to use the first network device so if you have several (like a wifi extension) you’d have some more work to do.
using System;
using Microsoft.SPOT;
using Dpws.Device;
using Ws.Services;
using Ws.Services.Binding;
using System.Ext;
namespace TestWPF
{
public class Program
{
public static void Main()
{
Microsoft.SPOT.Net.NetworkInformation.NetworkInterface NI = Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0];
if (NI.IsDhcpEnabled == false)
{
Debug.Print("Enabling DHCP.");
NI.EnableDhcp();
Debug.Print("DCHP - IP Address = " + NI.IPAddress + " ... Net Mask = " + NI.SubnetMask + " ... Gateway = " + NI.GatewayAddress);
}
else
{
Debug.Print("Renewing DHCP lease.");
NI.RenewDhcpLease();
Debug.Print("DCHP - IP Address = " + NI.IPAddress + " ... Net Mask = " + NI.SubnetMask + " ... Gateway = " + NI.GatewayAddress);
}
// Initialize the binding
//Guid g = Guid.NewGuid();
string guid = "urn:uuid:18571766-87df-06e2-bb68-5136c48f483f";
// ProtocolVersion10 can be used only if the corresponding HelloWorldClient_WCF application
// uses a custom binding with Soap12WSAddressingAugust2004 text message encoding.
ProtocolVersion version = new ProtocolVersion11();
WS2007HttpBinding binding = new WS2007HttpBinding(new HttpTransportBindingConfig(guid, 8084));
// maybe due to this returns empty:WsNetworkServices.GetLocalIPV4Address()
string uri = binding.Transport.EndpointAddress.AbsoluteUri;
Device.Initialize(binding, version);
//Device.Initialize(new WS2007HttpBinding(new HttpTransportBindingConfig(new System.Uri("http://192.168.1.101:8084", UriKind.Absolute))), version);
// Set device information
//Device.ThisModel.Manufacturer = "GHI Electronics";
//Device.ThisModel.ManufacturerUrl = "http://www.GHI Electronics.com/";
//Device.ThisModel.ModelName = "Chipworks MINI9261I";
//Device.ThisModel.ModelNumber = "1.4";
//Device.ThisModel.ModelUrl = "http://www.GHI Electronics.com/";
//Device.ThisModel.PresentationUrl = "http://www.GHI Electronics.com/";
//Device.ThisDevice.FriendlyName = "HelloWorldService";
//Device.ThisDevice.FirmwareVersion = "4.1.7.0";
//Device.ThisDevice.SerialNumber = "32345678";
string ip = Device.IPV4Address;
Console.Write(ip);
// Add a Host service type
//Device.Host = new HelloWCFService(version);
// Add Dpws hosted service(s) to the device
//Device.HostedServices.Add(new IServiceHelloWCF(new wcfTestImplement()));
// Set this device property if you want to ignore this clients request
Device.IgnoreLocalClientRequest = true;
// Turn console messages on
Console.Verbose = true;
System.Ext.Console.Write("Start DPWS device service with endpoint address: '" + Device.EndpointAddress + "'");
ServerBindingContext ctx = new ServerBindingContext(version);
try
{
// Start the device
Device.Start(ctx);
}
catch (Exception e)
{
System.Ext.Console.Write(e.ToString());
throw;
}
}
}
}
Thx very much!
I knew the issue should be trivial, but it just confusing so much. I now run it successfully as I add some network configuration into it.
I think it should be wrong setting with WFDeploy to set network.