简体   繁体   English

在WP8上使用WCF进行LINQ to SQL时,出现“ System.InvalidOperationException”

[英]'System.InvalidOperationException' when LINQ to SQL using WCF on WP8

This is the code where the exception occurs: 这是发生异常的代码:

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
    }

I get following Exception: 我得到以下异常:

An exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.ni.dll but was not handled in user code

I would like to say that I directly followed this tutorial on MSDN 我想说我直接在MSDN上遵循了本教程

So the final Service Reference url is: http:// IP /WcfTours/ServiceTours.svc as it should be. 因此,最终的服务参考URL为:http:// IP /WcfTours/ServiceTours.svc。 //99.99.99 represents IP //99.99.99代表IP

World Wide Web Services (HTTP) in Allow an app through Windows Firewall is allowed for domain public and private . domain publicprivate允许Allow an app through Windows Firewall World Wide Web Services (HTTP)

Virtual Directory is created. Virtual Directory已创建。

Will somebody please help me with setting the endpoint please ? 有人可以帮我设置endpoint吗?

Exception message: 异常消息:

{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 {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) 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()} {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(字符串端点配置名称,EndpointAddress remoteAddress) 1.CreateSimplexFactory() at System.ServiceModel.ClientBase 1处1.CreateSimplexFactory() at System.ServiceModel.ClientBase CreateSimplexFactory 1.CreateSimplexFactory() at System.ServiceModel.ClientBase1..ctor() at PhoneApp1.ServiceTours.ServiceToursClient..ctor() at PhoneApp1.Listado.ListadoWebService() at PhoneApp1.Listado..ctor()} 1 endpointTrait) at System.ServiceModel.ClientBase 1.InitializeChannelFactoryRef()的System.ServiceModel.ClientBase的CreateChannelFactoryRef(EndpointTrait 1 endpointTrait) at System.ServiceModel.ClientBase 1..ctor() at PhoneApp1.ServiceTours.ServiceToursClient..ctor() at PhoneApp1.Listado.ListadoWebService() at PhoneApp1.Listado..ctor()}

As soon as you add a Web Service reference in your project a new ServiceReferences.ClientConfig file is created in the root folder of your project. 在项目中添加Web Service引用后,就会在项目的根文件夹中创建一个新的ServiceReferences.ClientConfig文件。 Open it somewhere and look for: 在某个地方打开它并寻找:

<client>
    <endpoint .... name="endpointName" />
<endpoint .... name="endpointName2" />
</client>

In your case you have more than one records there. 就您而言,那里有多个记录。 so select the appropriate and pass the name into contructor of ServiceToursClient. 因此,请选择适当的名称并将其传递给ServiceToursClient的构造函数。

new ServiceToursClient("endpointName")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从WP8中的xml读取时出现System.InvalidOperationException - System.InvalidOperationException when reading from xml in WP8 WCF System.InvalidOperationException - WCF System.InvalidOperationException 调用WCF服务时出现System.InvalidOperationException - System.InvalidOperationException when calling WCF Service WCF和EF中的System.InvalidOperationException - System.InvalidOperationException in WCF and EF System.InvalidOperationException:LINQ 表达式 - System.InvalidOperationException: The LINQ expression Linq to SQL System.InvalidOperationException:成员自动同步失败 - Linq to SQL System.InvalidOperationException : Member AutoSync failure System.InvalidOperationException: LINQ 表达式 'GroupByShaperExpression: - System.InvalidOperationException: The LINQ expression 'GroupByShaperExpression: 将 GetAwaiter().GetResult() 与 ServiceBusReceiver.PeekMessagesAsync 一起使用时出现 System.InvalidOperationException - System.InvalidOperationException when using GetAwaiter().GetResult() with ServiceBusReceiver.PeekMessagesAsync 在Main中使用Keyboard.IsKeyDown()时出现System.InvalidOperationException - System.InvalidOperationException when using Keyboard.IsKeyDown() in Main 将我的 SQL 转换为 LINQ 并且我收到 System.InvalidOperationException: Client side GroupBy is not supported 错误 - Converted my SQL to LINQ and I am getting System.InvalidOperationException: Client side GroupBy is not supported error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM