Click here to Skip to main content
13,046,660 members (68,496 online)
Rate this:
Please Sign up or sign in to vote.
See more:
"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host"

I am getting the above error in my desktop application when i call to webservice.
i ahve one method in webservice which searches the virtual path on server. when i call to this method , i have got the aboove error. I have checked the same path on my server and it is properly working

Webservice :-

<WebMethod(Description:="Retrieve an array of files with name, attributes and content.")> _
Public Function Browse(ByVal VirtualPath As String, ByVal FileExtension As FileExtensions) As FileInformation()
       Dim i As Integer
       Dim fi As FileInfo
       Dim aFiles As FileInformation()
       Dim mExtension As String
       Select Case FileExtension
           Case FileExtensions.asp
               mExtension = "asp"
           Case FileExtensions.aspx
               mExtension = "aspx"
           Case FileExtensions.gif
               mExtension = "gif"
           Case FileExtensions.htm
               mExtension = "htm"
           Case FileExtensions.html
               mExtension = "html"
           Case FileExtensions.jpg
               mExtension = "jpg"
           Case FileExtensions.dll
               mExtension = "dll"
           Case FileExtensions.exe
               mExtension = "exe"
           Case FileExtensions.all
               mExtension = "*"
       End Select
       Dim di As New DirectoryInfo(WebServerPath & VirtualPath)
       Dim afi As FileInfo() = _
        di.GetFiles("*." & mExtension)
       ReDim Preserve aFiles(afi.Length - 1)
       For Each fi In afi
           aFiles(i) = New FileInformation()
           aFiles(i).Name = fi.Name
           aFiles(i).Size = fi.Length
           aFiles(i).LastAccess = fi.LastAccessTime
           aFiles(i).CreadedDate = fi.CreationTime
           aFiles(i).LastModified = fi.LastWriteTime
           aFiles(i).FileType = fi.Extension
           aFiles(i).FileLocation = fi.DirectoryName
           aFiles(i).FileContent = ReadFile(WebServerPath & VirtualPath & "\" & fi.Name)
           i += 1
       Return aFiles
   End Function

in web.config of webservice:-

<?xml version="1.0" encoding="utf-8"?>

        <add key="WebServerRootPath" value="c:\inetpub\wwwroot\" />

In my desktop application :-

'webreference name :- WSFileSever
'webservice name :- FileServer
'Webmethod :- Browse
mWSFileServer = New WSFileSever.FileServer()
 mFileInformation = mWSFileServer.Browse("microt/", WSFileSever.FileExtensions.all)

Please help me its urgent
Posted 11-Jul-12 19:41pm
bluesathish 25-Jul-12 6:36am
Post your web.config entries, Let me check. This error may be occured due to the binding settings.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 12 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100