|
-
Feb 1st, 2005, 07:05 AM
#1
Thread Starter
Fanatic Member
SOCKET ERROR : Cannot access a disposed object
im kinda using ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpguide/html/cpconnon-blockingserversocketexample.htm
as my example to socket programming
for u that dont have msdn = http://msdn.microsoft.com/library/de...ketexample.asp
I am getting an error of
System.ObjectDisposedException: Cannot access a disposed object named "System.Net.Sockets.Socket".
Object name: "System.Net.Sockets.Socket".
at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
at SpiderCheck.Class1.ReceiveCallback(IAsyncResult ar) in C:\Development\SpiderManager\SpiderCheck\Class1.vb:line 165
I know what the problem is however im not sure on how to resolve it
The problem is that the socket is getting dropped when the thread is terminated and that the BeginReceive method still has information coming in.
This works ok when its a single call to the server but i need to run my methods within a loop, this is where the problem is caused.
Could anyone advise on how to resolve this issue. ask if you wish to see the code snippets
Thanks in advance
Carl
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Feb 1st, 2005, 10:48 AM
#2
Thread Starter
Fanatic Member
Re: SOCKET ERROR : Cannot access a disposed object
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Feb 1st, 2005, 07:34 PM
#3
Addicted Member
Re: SOCKET ERROR : Cannot access a disposed object
use timers.... they are much more performance-friendly then using a loop
sockets.... havent worked much with these. Sorry I cant be of more help
-
Feb 2nd, 2005, 03:08 AM
#4
Thread Starter
Fanatic Member
Re: SOCKET ERROR : Cannot access a disposed object
ive managed to fix it strange thing is i was doing a call to my socket dll and updating a list box within a loop i seperated the call to my dll in to a function and now it works like a dream
but i dont understand why ?
I am curretly building a defect management system for software and web developers,
If you wana try it out (beta test) and keep it for free just send me a message
-
Feb 2nd, 2005, 03:41 AM
#5
Member
Re: SOCKET ERROR : Cannot access a disposed object
what do you make somthing on internet, winsock is a good a very good
script for internet but microsoft change it in a script a dam script maybe can you find somthing beters on this site 
www.planetsourcecode.com
-
Feb 2nd, 2005, 03:46 AM
#6
Re: SOCKET ERROR : Cannot access a disposed object
Hi
I had a similar problem i have a form with a crystalreportviewer and once i closed the form while the report was still pulling data and i receive a similar error.
Regards
Jorge
"The dark side clouds everything. Impossible to see the future is."
-
Feb 2nd, 2005, 11:00 AM
#7
Frenzied Member
Re: SOCKET ERROR : Cannot access a disposed object
carlblanchard, are you trying to use a socket again after it's already been closed? If so, you can't do that, as the .Close() method calls dispose, and you get that error.
The workaround is to just create a new socket rather than trying to open one that has been closed/disposed.
HTH,
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|