How do I code for this?  
Author Message

PostPosted: Visual C# General, How do I code for this? Top

My application reads a text file in, removes any trailing spaces from each line in ths file and writes it out to a text file. Simple enough I thought. The user has encountered this criptic message and I have no ideas as to it's source nor how to correct it. Is this error from my code or did the system 'hiccup' and interupt the process

The Dialog title is: File Trimmer.exe - Common Language Runtime Debugging Services

The body of the message:

Application has generated an exception that could not be handled.

Process id=0x914(2324), Thread id=0xf58(3928).

Click OK to terminate the application.
Click CANCEL to debug the application.

I've tried to locate where this may have occured to no avail. I've double-checked and I have try/catch in all methods that do any file processing.

This is very puzzleing. Does anyone have a clue

Thank you.

Visual C#7  

PostPosted: Visual C# General, How do I code for this? Top

Depending on how the program is reading the file and processing it could be a couple of things, such as the End of Line (EOL) character may not be handled properly depending on how the file is being read. Do this check list:
  1. Has EOL condition been done before processing. (This is dependent on how the code is doing the processing, since the code was not provided I must put this in.)
  2. Has the line read been checked to see if it actually has information by calling if (string.IsNullOrEmpty(<line>) == false) { ... do processing ... }.
  3. Instead of processing the file line by line, read the file into a buffer and use Regex.Replace do the work over the whole how file. That limits possible problems to file open, regex processing and file close.
  4. File may be opened and locked by another process, saving could cause a problem.
  5. If using streams, make sure to check for null streams or file handles...
  6. Try/catch around file open and close as well.
Just some thoughts...good luck.

Charlie Calvert MSFT

PostPosted: Visual C# General, How do I code for this? Top

Do you have the document that was being processed when the error occurred Can you reproduce it

Being able to step through this with the de**** would be helpful.

- Charlie


PostPosted: Visual C# General, How do I code for this? Top

I found the problem. Thank you for your help. I couldn't duplicate the problem at all. I finally went to our security dept and found that this was caused when an instance of the app was "untrusted". I found out the user was new to the system and had to process the file for another person. I walked them thru the process to set the app to be "trusted" on their machine and all is well.

I should've thought about that first, this hasn't happened in a long while and I had forgotten all about the untrusted application issue.

Thank you all again, I really appreciate your help.