error CS0117:'System.Exception' does not contain a definition for 'Error'

catch(System.Exception e)
{
for(int i=0;i<e.Error.Count;i++)
{
_errInfo += "Error Sequential Nubmer:" +i+ "\n" + "Error Info:" + e.ErrorIdea.Message + "\n" + "Error Source:" + e.ErrorIdea.Source + "\n" + "Program:" +e.ErrorIdea.Procedure;
}




Answer this question

error CS0117:'System.Exception' does not contain a definition for 'Error'

  • Pockey

    Rick, your help is sincerely appreciated!

    Then, in this case, how can I get the error infomation once exception occur



  • Dave Comer

    System.Exception contains several properties which give some information about the exception that occurred.

    If you would like to know how to check at which method the exception occurred, and in which object, you could do this with reflection. This is rather expensive, but might be useful... For more information, read this post on my blog.

  • dto

    Nope, you thought wrong. There is no similar mechanism for a normal Exception. You could take a look at the InnerException, but that's not the same kind of info. A SqlException overrides System.Exception, and can contain (much) more functionality and data than a normal Exception.

    If you want this info, you'll have to get it yourself. Please take a look at the MSDN Library information on System.Exception members to see which info it contains and which it doesn't.

  • Bhasker

    You are trying to read the Error property from an Exception. But System.Exception doesn't have an Error property. That's why you get this error.

  • spartakiran

    Rick, thks. But in the following snippet, System.Exception was replaced by SqlException, and the code works quite well. So, I think there must be similiar mechenism for System.Exception just as Error for SqlException.

     

    catch(SqlException e)//<--works quite well!
       {
        for(int i=0;i<e.Errors.Count;i++)
        {
         errInfo+="Error Sequential Number:" +i+ "\n" + "Error Info:" +e.ErrorsIdea.Message+ "\n" + "Error Source:" +e.ErrorsIdea.Source+ "\n" + "Program:" +e.ErrorsIdea.Procedure;
        }



  • Gerhard Brueckl

    OK, thks a lot.

  • error CS0117:'System.Exception' does not contain a definition for 'Error'