Code Execution Just Stops

A

Adrian Enders

I have something that I have never seen before in a MS development product.
I have a pretty simple call to a network directory that looks something like
this ...

Dim dirFolder As System.IO.DirectoryInfo

dirFolder = New System.IO.DirectoryInfo(sFilePath)

Dim filFiles() As System.IO.FileInfo

filFiles = dirFolder.GetFiles("*.xml")



filFiles should contain all XML files in the sFilePath directory. The
problem that I am having is that code execution simply stops on the last
line, even when running in debug. Period. I have tried surrounding this with
a Try Catch Finally block ... no exceptions are captured. Code execution
simply stops. It won't even advance to the next line of code. Has anyone
ever seen anything like this? Background: This is a windows service
application. I am simply trying to parse through all XML files in a
specified directory. Am I doing something wrong that I am not aware of?
Above all of that, why does the code just stop? I haven't even seen this
kind of behavior in VB6. I have to admit, I am a little uncomfortable with
just halting execution.

Thanks.



Adrian

Programmer/Analyst
 
H

Herfried K. Wagner [MVP]

Adrian Enders said:
I have something that I have never seen before in a MS development product.
I have a pretty simple call to a network directory that looks something
like
this ...

Dim dirFolder As System.IO.DirectoryInfo

dirFolder = New System.IO.DirectoryInfo(sFilePath)

Dim filFiles() As System.IO.FileInfo

filFiles = dirFolder.GetFiles("*.xml")



filFiles should contain all XML files in the sFilePath directory. The
problem that I am having is that code execution simply stops on the last
line, even when running in debug. Period. I have tried surrounding this
with
a Try Catch Finally block ... no exceptions are captured. Code execution
simply stops. It won't even advance to the next line of code. Has anyone
ever seen anything like this? Background: This is a windows service
application. I am simply trying to parse through all XML files in a
specified directory. Am I doing something wrong that I am not aware of?

How long did you wait? Maybe the application is attempting to access the
network directory and waits until a timeout occurs because it cannot reach
it (missing privileges?).
 
A

Adrian Enders

Herfried K. Wagner said:
How long did you wait? Maybe the application is attempting to access the
network directory and waits until a timeout occurs because it cannot reach
it (missing privileges?).

A good thought, but not it, thanks. You did get me looking at permissions
though. I have it running now ... it was the log in settings for the service
itself that did not have permissions to the that directory. By changing the
log in for the service itself, instead of letting it default to "Local
System", I was able to get the code to continue. I do not understand why
there was no exception, no error. The code simply stopped executing, until
it was time to fire again. I have this service set up on a timer that checks
a database to see if it is time to process. The timer event would fire, but
the code would just stop. Then the timer would fire again ... weird. And
disconcerting. Thanks for the help!
 
P

Peter Huang [MSFT]

Hi

I agree with Herfried's suggestion.
Because this is a network shared folder, and the OS will consider the
network connection status, there will be a timeout if we have permission or
network connection issue.
For the timer issue, I think you may try to take a look at the article
below about the three kinds of timer in .NET framework.

Unlike the System.Windows.Forms.Timer, the System.Timers.Timer class will,
by default, call your timer event handler on a worker thread obtained from
the common language runtime (CLR) thread pool.
http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/default.aspx

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Adrian Enders

"Peter Huang" said:
Hi

I agree with Herfried's suggestion.
Because this is a network shared folder, and the OS will consider the
network connection status, there will be a timeout if we have permission or
network connection issue.
For the timer issue, I think you may try to take a look at the article
below about the three kinds of timer in .NET framework.

Unlike the System.Windows.Forms.Timer, the System.Timers.Timer class will,
by default, call your timer event handler on a worker thread obtained from
the common language runtime (CLR) thread pool.
http://msdn.microsoft.com/msdnmag/issues/04/02/TimersinNET/default.aspx

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Thanks for the input. I am using "System.Timers.Timer" class. And the
correct answer was permissions. But why does code execution just stop? I
have waited well past a timeout phase. There never is an error returned to
the code and code execution still just stops. At the timeout point I should
at least get an error that I can trap ... "Permission Denied", "You do not
have access ...", something. I get nothing. Code just stops until the next
timer event is fired. I am going to see if I can figure this out once this
project is complete. :) Thanks for the assist gentlemen! Much appreciated.

Adrian
 
P

Peter Huang [MSFT]

Hi

Thanks for your feedback.
I think why the code stoped is because the .NET code is trying to access to
an underlying file system and the file system will try to redirect the
request to the network shared folder which is served by the other machine's
Server Service.

I think windows consider the components stand alone, Also the .NET class is
high abstracted, which will conceal some information from the lower level
class. From the MSDN, we know that the public FileInfo[] GetFiles() method
did not define any exceptions. So I think the information may have been
caught. Because it think it is the low level functional class to handle the
network/security or else issue. The public FileInfo[] GetFiles(); will just
return the file list.

So I think the timeout is the network sharing provider's job to handle and
the System.Timers.Timer is running on the system's thread pool so it will
continue running.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top