Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
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 :-

VB
<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
       Next
       Return aFiles
   End Function


in web.config of webservice:-

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

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



In my desktop application :-

VB
'webreference name :- WSFileSever
'webservice name :- FileServer
'Webmethod :- Browse

mWSFileServer = New WSFileSever.FileServer()

 mFileInformation = mWSFileServer.Browse("microt/MicroLNTS.net/Common/NewCarmsDownloads/MicroCramsLNTSWin7HomePre64bit", WSFileSever.FileExtensions.all)


Please help me its urgent
Posted
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900