这是发生异常的代码:
public Listado()
{
InitializeComponent();
ListadoWebService();
}
public void ListadoWebService()
{
// InitializeComponent();
ServiceTours.ServiceToursClient cl = new ServiceTours.ServiceToursClient();
cl.ListadoCompleted += new EventHandler<ListadoCompletedEventArgs>(Listado2);
cl.ListadoAsync();
}
private void Listado2(object sender, ListadoCompletedEventArgs e)
{
listB.ItemsSource = e.Result; // listB is ListBox in WP8
}
我得到以下异常:
An exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.ni.dll but was not handled in user code
我想说我直接按照MSDN上的这个教程
所以最终的服务参考 url 应该是:http:// IP /WcfTours/ServiceTours.svc。//99.99.99代表IP
World Wide Web Services (HTTP)
inAllow an app through Windows Firewall
允许domain
public
和private
。
Virtual Directory
被建造。
有人可以帮我设置endpoint
好吗?
异常消息:
{System.InvalidOperationException: An endpoint configuration section for contract 'ServiceTours.IServiceTours' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.
at System.ServiceModel.Description.ConfigLoader.LookupChannel(String configurationName, String contractName, Boolean wildcard)
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory
1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) 在 System.ServiceModel.EndpointTrait 1.CreateChannelFactoryRef 1.CreateSimplexFactory()
at System.ServiceModel.ClientBase
(EndpointTrait 1 endpointTrait)
at System.ServiceModel.ClientBase
1.InitializeChannelFactoryRef() 在 System.ServiceModel.ClientBase1..ctor()
at PhoneApp1.ServiceTours.ServiceToursClient..ctor()
at PhoneApp1.Listado.ListadoWebService()
at PhoneApp1.Listado..ctor()}