繁体   English   中英

从服务参考创建WCF客户端时,MessageSecurityOverHttpElement中的IndexOutOfRangeException

[英]IndexOutOfRangeException in MessageSecurityOverHttpElement when creating WCF client from service reference

我有一个在数千人使用的应用程序中使用“添加服务引用”创建的普通WCF服务引用。

使用new MyServiceClient()创建客户端的实例,并且该实例的99%的时间正常工作,但是对于某些用户,它可能会因IndexOutOfRangeException失败。 我一直无法复制,但是从我的错误报告中看来,它可能仅在应用程序设置为从Windows启动时才会发生,那么启动时可能会与某些基础Windows服务发生某种竞争情况吗?

Exception (-2146233080): 
System.IndexOutOfRangeException: Index was outside the bounds of the array. 
at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext() 
at System.Configuration.PropertyInformationCollection..ctor(ConfigurationElement thisElement) 
at System.ServiceModel.Configuration.MessageSecurityOverHttpElement.ApplyConfiguration(MessageSecurityOverHttp security) 
at System.ServiceModel.Configuration.NonDualMessageSecurityOverHttpElement.ApplyConfiguration(NonDualMessageSecurityOverHttp security) 
at System.ServiceModel.Description.ConfigLoader.LookupBinding(String bindingSectionName, String configurationName, BindingCollectionElement bindingCollectionElement, Binding defaultBinding) 
at System.ServiceModel.Description.ConfigLoader.LookupBinding(String bindingSectionName, String configurationName, ContextInformation context)
at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName) 
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration) 
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address) 
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress) 
at System.ServiceModel.ConfigurationEndpointTrait`1.CreateSimplexFactory() 
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait) 
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
<system.serviceModel>
  <bindings>
    <wsHttpBinding>
      <binding name="WSHttpBinding_IMyService">
        <security mode="Transport">
          <transport clientCredentialType="None" />
        </security>
      </binding>
    </wsHttpBinding>
  </bindings>
  <client>
    <endpoint address="https://xxxxxxxx.com/Services/MyService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService" contract="MyService.IMyService" name="WSHttpBinding_IMyService" />
  </client>
</system.serviceModel>

我还没有遇到类似的问题。 该错误表明您正在尝试访问ArrayList中不存在的索引,换句话说,该索引超出范围。
如果错误发生在客户端,我认为可能是客户端环境导致了此问题。 例如,是否安装了相应的dotnetframework运行时版本,系统有问题? 尝试解决这些问题,然后删除并重新添加服务引用。
随时让我知道问题是否仍然存在。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM