Main Content

NET.NetException

捕获 .NET 异常的错误信息

    说明

    捕获来自 NET.NetException 对象的信息以处理 .NET 错误。此类派生自 MException

    创建对象

    描述

    示例

    e = NET.NetException(msgID,errMsg,netObj) 构造 NET.NetException 类的实例 e

    输入参量

    全部展开

    消息标识符,指定为字符串或字符向量。

    错误消息文本,指定为字符串或字符向量。

    导致异常的 .NET 对象,指定为 System.Exception 对象。

    属性

    全部展开

    导致错误的类,指定为 System.Exception 对象。

    对象函数

    请参阅 MException 的对象函数。

    示例

    全部折叠

    试图加载未知程序集后显示错误信息。

    try
      NET.addAssembly('C:\Work\invalidfile.dll')
    catch e
      e.message;
      if(isa(e, 'NET.NetException'))
        eObj = e.ExceptionObject
      end
    end
    ans =
    Message: Could not load file or assembly 
      'file:///C:\Work\invalidfile.dll' or 
      one of its dependencies. The system cannot 
      find the file specified.
    Source: mscorlib
    HelpLink: 
    
    eObj = 
      FileNotFoundException with properties:
    
               Message: [1x1 System.String]
              FileName: [1x1 System.String]
             FusionLog: [1x1 System.String]
                  Data: [1x1 System.Collections.ListDictionaryInternal]
        InnerException: []
            TargetSite: [1x1 System.Reflection.RuntimeMethodInfo]
            StackTrace: [1x1 System.String]
              HelpLink: []
                Source: [1x1 System.String]
    

    版本历史记录

    在 R2009b 中推出

    另请参阅