CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2008
    Posts
    1

    C# - APP: Exception: The operation was canceled.

    Hi all,
    i need help with one exception. I know only .Message of this exception and i know which part of code throws it.


    Message:
    .Message: "The operation was canceled."




    Code:
    Code:
    try
                            {
                                FileIOPermission perm = new FileIOPermission(FileIOPermissionAccess.Write, file_name);
                                perm.Assert();
                                if (!additive && File.Exists(file_name)) File.Delete(file_name);
                                using(FileStream fs = new FileStream(file_name, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                                {
                                    using(StreamWriter writer = new StreamWriter(fs))
                                    {
                                        writer.BaseStream.Seek(0, SeekOrigin.End);
                                        writer.Write(content);
                                        writer.Flush();
                                        writer.Close();
           
                                        result = true;
                                    }
                                    fs.Close();
                                }
                                CodeAccessPermission.RevertAssert();
                            }
                            catch (System.Exception err)
                            {
                                System.Diagnostics.Debug.WriteLine(err.Message);
                                throw(err);
                            }
    FYI: This Windows application runs for many years, but once this error was occured and stored in log. Can somebody help me? Is anythere List of exception messages, where I can find what does the exception mean?
    Last edited by cjard; July 31st, 2008 at 12:03 PM.

  2. #2
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: C# - APP: Exception: The operation was canceled.

    change this line:

    Code:
    System.Diagnostics.Debug.WriteLine(err.Message);
    to

    Code:
    System.Diagnostics.Debug.WriteLine(err.ToString());
    you will also get the stack trace when writing the entire error.

  3. #3
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    Re: C# - APP: Exception: The operation was canceled.

    Quote Originally Posted by strakamichal
    This Windows application runs for many years, but once this error was occured and stored in log.
    It ran for years and you care that this error happened once? Wow.. Not much to do at your work eh?
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured