基础连接已关闭:在wcf服务中,连接意外关闭. [英] The underlying connection was closed: The connection was closed unexpectedly in wcf service.

查看:115
本文介绍了基础连接已关闭:在wcf服务中,连接意外关闭.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1.无法调用服务.可能的原因:服务离线或无法访问;客户端配置与代理不匹配;现有代理无效.有关更多详细信息,请参考堆栈跟踪.您可以尝试通过启动新代理,恢复为默认配置或刷新服务来恢复.

1.Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proy, restoring to default configuration, or refreshing the service.

Error is : The underlying connection was closed: The connection was closed unexpectedly.


这是我的3个文件...

Iservice1.cs


this is my 3 file...

Iservice1.cs

[OperationContract]
        List<Vehicle_Master> GetVehicle();


Service1.svc.cs


Service1.svc.cs

public List<Vehicle_Master> GetVehicle()
        {
            //Configuration.ProxyCreationEnabled = false;
            var result = (from var in dcdc.Vehicle_Masters select var).ToList();
            return result.ToList();
        }


Web.config


Web.config

<configuration>
	
  <connectionstrings>
    <add name="Database1ConnectionString1" connectionstring="Data Source=najar-pc\sqlexpress;Initial Catalog=Database1;Integrated Security=True">
      providerName="System.Data.SqlClient" />
  </add></connectionstrings>
  <system.web>
    <compilation debug="true" targetframework="4.0" />
  </system.web>
  <system.servicemodel>
    <behaviors>
      <servicebehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <servicemetadata httpgetenabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <servicedebug includeexceptiondetailinfaults="false" />
        </behavior>
      </servicebehaviors>
    </behaviors>
    <servicehostingenvironment multiplesitebindingsenabled="true" />
  </system.servicemodel>
 <system.webserver>
    <modules runallmanagedmodulesforallrequests="true" />
  </system.webserver>
  
</configuration>


我花了很多时间,但我还没有解决.请帮助我..


I have spend so much time but i have not solve it. please help me..

推荐答案

将您的集合作为数组(而不是WCF)返回总是一个好主意.

请在您的申请中检查以下内容

->您的对象内部有一些未初始化的对象,并且没有被序列化.
->将签名从列表转换为数组(始终是避免脏序列化问题的好主意)
Its always a good idea to return your collection as an Array rather a lit from WCF .

Please check the following in your applicaiton

--> Your object has some some uninitialised object internally and its not getting serialized.
--> Convert signature from List to Array (always a good idea to avoid dirty serialization issues )


这篇关于基础连接已关闭:在wcf服务中,连接意外关闭.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆