久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

為什么我應(yīng)該總是讓我的異常[可序列化]?(.網(wǎng))

Why should I always make my Exceptions [serializable]? (.NET)(為什么我應(yīng)該總是讓我的異常[可序列化]?(.網(wǎng)))
本文介紹了為什么我應(yīng)該總是讓我的異常[可序列化]?(.網(wǎng))的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習吧!

問題描述

參考使自定義.NET Exception 可序列化的正確方法是什么?
和 所有 .NET 異常都可序列化嗎? ...

為什么我的異常應(yīng)該是可序列化的?
有人說,如果第三方庫定義的自定義異常是不可序列化的,它可以被認為是一個錯誤".為什么?

Why should my exceptions be serializable?
Someone said "it can be considered a bug" if a custom exception defined by a third party library, is not serializable. Why?

為什么在這方面異常與其他類不同?

Why are exceptions different than other classes in this regard?

推薦答案

因為您的異??赡苄枰诓煌?AppDomain 之間進行編組,如果它們不能(正確)序列化,您將丟失寶貴的調(diào)試信息.與其他類不同,您無法控制您的異常是否會被編組——它會.

Because your exceptions may need to be marshalled between different AppDomains and if they aren't (properly) serializable you will lose precious debugging information. Unlike other classes, you won't have control over whether your exception will be marshalled -- it will.

當我的意思是你將無法控制"時,我的意思是你創(chuàng)建的類通常具有有限的存在空間,并且存在是眾所周知的.如果它是一個返回值并且有人試圖在不同的 AppDomain(或在不同的機器上)調(diào)用它,他們會得到一個錯誤,并且可以說不要那樣使用它".調(diào)用者知道他們必須將其轉(zhuǎn)換為可以序列化的類型(通過包裝方法調(diào)用).但是,由于如果沒有被捕獲,異常就會冒泡到最頂端,它們可以超越您甚至不知道的 AppDomain 邊界.您在不同 AppDomain 中的 20 級自定義應(yīng)用程序異??赡苁?Main() 報告的異常,并且在此過程中沒有任何東西可以將其轉(zhuǎn)換為您的可序列化異常.

When I mean "you won't have control" I mean that classes you create generally have a finite space of existence and the existence is well known. If it's a return value and someone tries to call it in a different AppDomain (or on a different machine) they will get a fault and can just say "Don't use it that way." The caller knows they have to convert it into a type that can be serialized (by wrapping the method call). However since exceptions are bubbled up to the very top if not caught they can transcend AppDomain boundaries you didn't even know you had. Your custom application exception 20 levels deep in a different AppDomain might be the exception reported at Main() and nothing along the way is going to convert it into a serializable exception for you.

這篇關(guān)于為什么我應(yīng)該總是讓我的異常[可序列化]?(.網(wǎng))的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Is there a way to know if someone has bookmarked your website?(有沒有辦法知道是否有人為您的網(wǎng)站添加了書簽?)
Use of Different .Net Languages?(使用不同的 .Net 語言?)
Determining an #39;active#39; user count of an ASP.NET site(確定 ASP.NET 站點的“活動用戶數(shù))
Best way to keep track of current online users(跟蹤當前在線用戶的最佳方式)
Recommend an Open Source .NET Statistics Library(推薦一個開源的.NET統(tǒng)計庫)
Create a summary description of a schedule given a list of shifts(給定輪班列表,創(chuàng)建時間表的摘要描述)
主站蜘蛛池模板: 久久久噜噜噜久久中文字幕色伊伊 | 久久亚洲国产 | 91在线一区二区三区 | 欧美三级在线 | 国产色婷婷精品综合在线手机播放 | 午夜噜噜噜 | 国产ts人妖系列高潮 | 在线国产视频 | 久久精品视频播放 | 国产精品视频久久久 | 亚洲国产成人久久综合一区,久久久国产99 | 日韩欧美三区 | 欧美日韩精品中文字幕 | 超黄毛片 | 国产精品日韩欧美一区二区 | 亚洲一区播放 | 99精品欧美一区二区三区 | 四虎影视在线 | 久久精品免费 | 日韩精品一区二区三区视频播放 | 日本高清不卡视频 | 亚洲a在线观看 | 日韩一区二区三区精品 | 一a级片| 亚洲欧美国产毛片在线 | 日本在线视频一区二区 | 一级毛片视频 | 亚洲狠狠 | 亚洲人成网站777色婷婷 | 天堂三级| 久久综合狠狠综合久久 | 特级丰满少妇一级aaaa爱毛片 | 黄色片视频网站 | aaaaaaa片毛片免费观看 | 亚洲一区二区精品视频在线观看 | 免费成人国产 | 国产午夜精品一区二区三区 | 在线不卡 | 一级毛片网 | 精品免费国产一区二区三区四区介绍 | 国产精品视频一区二区三区, |