Click here to Skip to main content
16,007,885 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Brady Kelly15-Jan-09 6:41
Brady Kelly15-Jan-09 6:41 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Luc Pattyn15-Jan-09 6:46
sitebuilderLuc Pattyn15-Jan-09 6:46 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Brady Kelly15-Jan-09 7:07
Brady Kelly15-Jan-09 7:07 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Luc Pattyn15-Jan-09 7:28
sitebuilderLuc Pattyn15-Jan-09 7:28 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Brady Kelly15-Jan-09 10:38
Brady Kelly15-Jan-09 10:38 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Luc Pattyn15-Jan-09 10:52
sitebuilderLuc Pattyn15-Jan-09 10:52 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Brady Kelly15-Jan-09 11:20
Brady Kelly15-Jan-09 11:20 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Luc Pattyn15-Jan-09 11:54
sitebuilderLuc Pattyn15-Jan-09 11:54 
Hi,

I ran the code below, which is basically yours (I now count the lines, and I fixed your Console output which was reading another line):

log("start");
FtpWebRequest req = (FtpWebRequest)FtpWebRequest.Create("ftp://ftp.microsoft.com");
req.Proxy = null;
req.Method = WebRequestMethods.Ftp.ListDirectory;
    using (FtpWebResponse res = (FtpWebResponse)req.GetResponse()) {
    StreamReader sr = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
    int count=0;
    for( ; ; ) {
        string fileName = sr.ReadLine();
        if (fileName==null) break;
        log(fileName);
        count++;
    }
    log("Received "+count+" lines");
}


and got what I was expecting:

23:46:20.277    CPTest.log-42                        start
23:46:25.932    CPTest.log-42                        bussys
23:46:25.945    CPTest.log-42                        deskapps
23:46:25.958    CPTest.log-42                        developr
23:46:25.970    CPTest.log-42                        KBHelp
23:46:25.983    CPTest.log-42                        MISC
23:46:25.996    CPTest.log-42                        MISC1
23:46:26.009    CPTest.log-42                        peropsys
23:46:26.037    CPTest.log-42                        Products
23:46:26.050    CPTest.log-42                        PSS
23:46:26.063    CPTest.log-42                        ResKit
23:46:26.077    CPTest.log-42                        Services
23:46:26.086    CPTest.log-42                        Softlib
23:46:26.281    CPTest.log-42                        Received 12 lines


So that tells me the Microsoft server and your client code are rather compatible, so there might be
something wrong with your Internet connection, although I can't begin to understand what it might be.
Is it special in any way? maybe extremely slow? I suggest you try with a well established FTP client so you can feel how it reacts, and maybe see some errors/warnings.

FYI: I did try Microsoft's site with FileZilla 3.1.2, and my Internet is a 3Mb/s ADSL.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

I use ListBoxes for line-oriented text output (not TextBoxes), and PictureBoxes for pictures (not drawings).


GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Brady Kelly15-Jan-09 12:06
Brady Kelly15-Jan-09 12:06 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Luc Pattyn15-Jan-09 12:47
sitebuilderLuc Pattyn15-Jan-09 12:47 
GeneralI suspect the problem is solved Pin
Luc Pattyn15-Jan-09 12:07
sitebuilderLuc Pattyn15-Jan-09 12:07 
GeneralRe: I suspect the problem is solved Pin
Brady Kelly15-Jan-09 22:16
Brady Kelly15-Jan-09 22:16 
GeneralRe: I suspect the problem is solved Pin
Luc Pattyn16-Jan-09 0:58
sitebuilderLuc Pattyn16-Jan-09 0:58 
GeneralRe: I suspect the problem is solved Pin
Brady Kelly16-Jan-09 1:57
Brady Kelly16-Jan-09 1:57 
GeneralRe: I suspect the problem is solved Pin
Luc Pattyn16-Jan-09 2:08
sitebuilderLuc Pattyn16-Jan-09 2:08 
GeneralRe: Cannot access a disposed object: Object name: ‘System.Net.Sockets.NetworkStream’. Pin
Brady Kelly15-Jan-09 6:44
Brady Kelly15-Jan-09 6:44 
GeneralRe: Textboxes Pin
Luc Pattyn15-Jan-09 6:53
sitebuilderLuc Pattyn15-Jan-09 6:53 
Questioncontrol.focus();???? Pin
bfis10813714-Jan-09 22:47
bfis10813714-Jan-09 22:47 
AnswerRe: control.focus();???? Pin
Eddy Vluggen14-Jan-09 23:04
professionalEddy Vluggen14-Jan-09 23:04 
GeneralI found the solution Pin
bfis10813714-Jan-09 23:12
bfis10813714-Jan-09 23:12 
QuestionWithevents for dynamicly created controls Pin
David Hovey14-Jan-09 17:16
David Hovey14-Jan-09 17:16 
GeneralRe: Withevents for dynamicly created controls Pin
Anshumas14-Jan-09 17:52
Anshumas14-Jan-09 17:52 
AnswerRe: Withevents for dynamicly created controls Pin
Dave Kreskowiak14-Jan-09 18:00
mveDave Kreskowiak14-Jan-09 18:00 
GeneralRe: Withevents for dynamicly created controls Pin
David Hovey16-Jan-09 8:17
David Hovey16-Jan-09 8:17 
QuestionCan't find System.EnterpriseServices.Wrapper.dll or one of it's dependencies Pin
mweingart14-Jan-09 6:18
mweingart14-Jan-09 6:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.