Autodesk.Revit.Exceptions.ApplicationException 表示在 Revit 应用程序中发生的异常。
System.Exception
Autodesk.Revit.Exceptions.ApplicationExceptionApplicationException()初始化 Autodesk.Revit.Exceptions.ApplicationException 类的新实例。
ApplicationException(String)使用指定的错误消息初始化 Autodesk.Revit.Exceptions.ApplicationException 类的新实例。
message:说明异常原因的错误消息。ApplicationException(SerializationInfo, StreamingContext)使用序列化数据初始化 Autodesk.Revit.Exceptions.ApplicationException 类的新实例。
以下示例演示如何使用 ApplicationException 处理 Revit 应用程序中的异常。
try
{
// Some Revit API code that may throw an exception
}
catch (Autodesk.Revit.Exceptions.ApplicationException ex)
{
// Handle application exceptions here
// ex.Message contains the error message
}
catch (System.Exception ex)
{
// Handle other exceptions here
}
可从 Revit 2017 开始使用 Autodesk.Revit.Exceptions.ApplicationException。