“System.InvalidOperationException” 当 LINQ to SQL 在 WP8 上使用 W
本文关键字:WP8 SQL to InvalidOperationException System LINQ | 更新日期: 2023-09-27 18:35:29
这是发生异常的代码:
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上遵循了本教程
因此,最终的服务参考网址是:http://IP/WcfTours/ServiceTours.svc,因为它应该是。//99.99.99 代表 IP
Allow an app through Windows Firewall
World Wide Web Services (HTTP)
允许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(字符串端点配置名称,端点地址远程地址) at System.ServiceModel.EndpointTrait 1.CreateSimplexFactory()
at System.ServiceModel.ClientBase
1.CreateChannelFactoryRef(EndpointTrait 1 endpointTrait)
at System.ServiceModel.ClientBase
1.InitializeChannelFactoryRef() at System.ServiceModel.ClientBase 1..ctor()
at PhoneApp1.ServiceTours.ServiceToursClient..ctor()
at PhoneApp1.Listado.ListadoWebService()
at PhoneApp1.Listado..ctor()}
在项目中添加 Web 服务引用后,将在项目的根文件夹中创建一个新的 ServiceReferences.ClientConfig 文件。在某处打开它并查找:
<client>
<endpoint .... name="endpointName" />
<endpoint .... name="endpointName2" />
</client>
在您的情况下,您那里有多个记录。 因此,选择适当的名称并将名称传递给ServiceToursClient的构造器。
new ServiceToursClient("endpointName")