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);
    }
  • 相关阅读:
    LeetCode-Palindrome Partitioning II
    LeetCode-Palindrome Partitioning
    LeetCode-Permutation Sequence
    LeetCode-Anagrams
    LeetCode-Text Justification
    LeetCode-Best Time to Buy and Sell Stock III
    LeetCode-Best Time to Buy and Sell Stock II
    LeetCode-Best Time to Buy and Sell Stock
    LeetCode-N-Queens II
    BZOJ 5390: [Lydsy1806月赛]糖果商店
  • 原文地址:https://www.cnblogs.com/yilang/p/13225001.html
Copyright © 2011-2022 走看看