Click here to Skip to main content
15,915,093 members
Home / Discussions / C#
   

C#

 
QuestionPrivate UDDI Pin
mughaldynasty6-Jul-07 12:38
mughaldynasty6-Jul-07 12:38 
QuestionFileStream Error ?? Pin
Richard Blythe6-Jul-07 9:13
Richard Blythe6-Jul-07 9:13 
AnswerRe: FileStream Error ?? Pin
Not Active6-Jul-07 9:41
mentorNot Active6-Jul-07 9:41 
AnswerRe: FileStream Error ?? Pin
Leslie Sanford6-Jul-07 10:07
Leslie Sanford6-Jul-07 10:07 
AnswerRe: FileStream Error ?? Pin
Guffa6-Jul-07 10:47
Guffa6-Jul-07 10:47 
AnswerRe: FileStream Error ?? Pin
Luc Pattyn7-Jul-07 2:13
sitebuilderLuc Pattyn7-Jul-07 2:13 
GeneralRe: FileStream Error ?? Pin
Richard Blythe7-Jul-07 13:51
Richard Blythe7-Jul-07 13:51 
GeneralRe: FileStream Error ?? Pin
Luc Pattyn7-Jul-07 14:33
sitebuilderLuc Pattyn7-Jul-07 14:33 
Hi,

I looked at your code (did not run it, I'm a C# guy) and have two suspicions
and several comments; here they are:

1.
it seldom is a good idea to have an empty catch block, since that really
hides any problems that might occur; you should fix that.

2.
rather than printing or showing Exception.Message I strongly advice everyone
to always use Exception.Totring since that gives a traceback plus additional
information depending on the kind of Exception, something Message cannot do
(e.g. the full file name if a file fails somehow, but also some inner exception
in case that occured)

3.
the reason your fs.Close() is in a try-catch with empty catch is, I guess,
that the file might not be open (because the open failed), hence now the
close will fail, and you dont want to see that. Fair enough, but then
you should test for it, as in:
if fs!=Nothing fs.Close() // I hope this is correct syntax for "fs is not nothing"

4.
I did not like GC.Collect() at the end of the reader. It seldom is wise to
attempt and help the GC, it normally is smart all by itself.

5.
suspicion 1:
I did not like ths fs.Dispose() that is present in the reader (but not in
the writer !?); I think it should not be there since fs.Close() takes care
of all resources, and MSDN says File.Dispose() is new since 2.0 but should
not be called ! Not sure how it would influence things tho.

6.
suspicion 2:
maybe, just maybe, your writing method is (sometimes) active while your reading
mehtod is active too, on a different thread. Make sure it is not. If both
do get called from different threads, try to devise a scheme in which the
reader gets aborted so the writer can succeed (a simple lock might not be
good enough since I guess you want to write upon app closure, and an ongoing
reader should not delay the closure)

You could inspect your code for threading stuff, and/or you could set a flag
while the reader is busy (and clear it when it's done), and test for that flag
inside the writer; doing so might confirm the occasional failure coincides with
concurrent reading/writing.

Hope this helps.

Smile | :)


QuestionAsynchornous error Pin
ramdil6-Jul-07 8:58
ramdil6-Jul-07 8:58 
AnswerRe: Asynchornous error Pin
mav.northwind6-Jul-07 10:16
mav.northwind6-Jul-07 10:16 
AnswerRe: Asynchornous error Pin
Luc Pattyn6-Jul-07 16:14
sitebuilderLuc Pattyn6-Jul-07 16:14 
GeneralRe: Asynchornous error Pin
mav.northwind6-Jul-07 22:43
mav.northwind6-Jul-07 22:43 
GeneralRe: Asynchornous error Pin
Luc Pattyn7-Jul-07 1:48
sitebuilderLuc Pattyn7-Jul-07 1:48 
GeneralRe: Asynchornous error Pin
mav.northwind7-Jul-07 4:03
mav.northwind7-Jul-07 4:03 
GeneralRe: Asynchornous error Pin
Luc Pattyn7-Jul-07 4:08
sitebuilderLuc Pattyn7-Jul-07 4:08 
Questionffmpeg and asp.net Pin
mfmaneef6-Jul-07 8:31
mfmaneef6-Jul-07 8:31 
QuestionTrying this again... (Import method from DLL) Pin
Azad Giordano Ratzki6-Jul-07 8:23
professionalAzad Giordano Ratzki6-Jul-07 8:23 
GeneralRe: Trying this again... (Import method from DLL) Pin
Guffa6-Jul-07 9:00
Guffa6-Jul-07 9:00 
AnswerRe: Trying this again... (Import method from DLL) Pin
Leslie Sanford6-Jul-07 9:24
Leslie Sanford6-Jul-07 9:24 
AnswerRe: Trying this again... (Import method from DLL) Pin
Not Active6-Jul-07 9:29
mentorNot Active6-Jul-07 9:29 
GeneralRe: Trying this again... (Import method from DLL) Pin
Azad Giordano Ratzki6-Jul-07 12:42
professionalAzad Giordano Ratzki6-Jul-07 12:42 
GeneralRe: Trying this again... (Import method from DLL) Pin
Luc Pattyn6-Jul-07 16:20
sitebuilderLuc Pattyn6-Jul-07 16:20 
QuestionDelegates in c# Pin
Malayil alex6-Jul-07 8:00
Malayil alex6-Jul-07 8:00 
AnswerRe: Delegates in c# Pin
led mike6-Jul-07 8:03
led mike6-Jul-07 8:03 
AnswerRe: Delegates in c# Pin
Martin#6-Jul-07 8:04
Martin#6-Jul-07 8:04 

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.