C# ';系统无效操作异常';在WP8上使用WCF将LINQ转换为SQL时
这是发生异常的代码:C# ';系统无效操作异常';在WP8上使用WCF将LINQ转换为SQL时,c#,wcf,linq-to-sql,windows-phone-8,C#,Wcf,Linq To Sql,Windows Phone 8,这是发生异常的代码: public Listado() { InitializeComponent(); ListadoWebService(); } public void ListadoWebService() { // InitializeComponent(); ServiceTours.ServiceToursClient cl = new ServiceTours.ServiceTours
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
}
public Listado()
{
初始化组件();
ListadoWebService();
}
public void ListadoWebService()
{
//初始化组件();
ServiceTours.ServiceToursClient cl=新的ServiceTours.ServiceToursClient();
cl.ListadoCompleted+=新事件处理程序(Listado2);
cl.ListadoAsync();
}
私有void Listado2(对象发送方,ListadoCompletedEventArgs e)
{
listB.ItemsSource=e.Result;//listB是WP8中的ListBox
}
我得到以下例外:
System.ServiceModel.ni.dll中发生“System.InvalidOperationException”类型的异常,但未在用户代码中处理该异常
我想说的是,我在上一节课上直接学习了本教程
因此,最终的服务参考url是:http://IP/WcfTours/ServiceTours.svc//99.99.99代表IP
万维网服务(HTTP)
中的允许应用通过Windows防火墙允许域公共和私有
虚拟目录
已创建
请有人帮我设置端点
好吗
异常消息:
{System.InvalidOperationException:无法加载协定“ServiceTours.IServiceTours”的终结点配置节,因为找到了该协定的多个终结点配置。请按名称指明首选终结点配置节。
位于System.ServiceModel.Description.ConfigLoader.LookupChannel(字符串configurationName、字符串contractName、布尔通配符)
位于System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint ServiceEndpoint,String configurationName)
位于System.ServiceModel.ChannelFactory.ApplyConfiguration(字符串配置名称)
位于System.ServiceModel.ChannelFactory.InitializeEndpoint(字符串配置名称,端点地址)
位于System.ServiceModel.ChannelFactory
1..ctor(字符串endpointConfigurationName,EndpointAddress remoteAddress)
在System.ServiceModel.EndpointTrait1.CreateSimplexFactory()中
位于System.ServiceModel.ClientBase
1.CreateChannelFactoryRef(EndpointTrait1 EndpointTrait)
位于System.ServiceModel.ClientBase
1.InitializeChannelFactoryRef()
在System.ServiceModel.ClientBase1..ctor()处
在PhoneApp1.ServiceTours.ServiceToursClient..ctor()上
在PhoneApp1.Listado.ListadoWebService()上
在PhoneApp1.Listado..ctor()}
中,一旦在项目中添加Web服务引用,就会在项目的根文件夹中创建一个新的ServiceReferences.ClientConfig文件。在某个地方打开它并查找:
<client>
<endpoint .... name="endpointName" />
<endpoint .... name="endpointName2" />
</client>
请告诉我们例外消息。@DanielHilgarth感谢您对我的帮助。请看编辑。现在,请阅读它并根据它行事。:-)如果您不知道如何执行,请询问有关错误消息的特定问题您只需在ServiceToursClient构造函数中指定端点配置名称。@VladimirGondarev我可以问一下如何执行吗?
new ServiceToursClient("endpointName")