zoukankan      html  css  js  c++  java
  • 关于异常System.ComponentModel.Win32Exception

    什么是Win32Exception

    就是封装了Win32 Error Code的异常。也就是GetLastError返回的值。Win32错误代码在显示时从其数字表示形式转换为系统消息。使用NativeErrorCode访问与此异常关联的错误代码的数字表示形式

    继承关系

    Object
    Exception
    SystemException
    ExternalException
    Win32Exception

    有如下子类

    System.Net.HttpListenerException
    System.Net.NetworkInformation.NetworkInformationException
    System.Net.Sockets.SocketException
    System.Net.WebSockets.WebSocketException

    HRESULT

    80004005

    下面的代码示例演示如何捕获Win32异常并解释其内容。该示例尝试启动不存在的可执行文件,这将导致Win32异常。在捕捉到异常时,该示例获取相应的错误消息、代码和异常的来源。

    try {
    System.Diagnostics.Process myProc = new System.Diagnostics.Process();
    myProc.StartInfo.FileName = "c:
    onexist.exe";  //Attempting to start a non-existing executable
    myProc.Start();    //Start the application and assign it to the process component.    
    }
    catch(Win32Exception w) {
    Console.WriteLine(w.Message);
    Console.WriteLine(w.ErrorCode.ToString());
    Console.WriteLine(w.NativeErrorCode.ToString());
    Console.WriteLine(w.StackTrace);
    Console.WriteLine(w.Source);
    Exception e=w.GetBaseException();
    Console.WriteLine(e.Message);
    }
  • 相关阅读:
    扑克牌大小
    简单错误记录
    聊天室
    GMM的EM算法实现
    Spark SQL 源代码分析之 In-Memory Columnar Storage 之 in-memory query
    JSP简单练习-使用JDOM创建xml文件
    PowerDesigner使用教程
    setsockopt()使用方法(參数具体说明)
    SQL注入原理解说,非常不错!
    Offer是否具有法律效力?
  • 原文地址:https://www.cnblogs.com/yilang/p/13225001.html
Copyright © 2011-2022 走看看