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

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

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

問(wèn)題描述

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

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

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?

為什么在這方面異常與其他類(lèi)不同?

Why are exceptions different than other classes in this regard?

推薦答案

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

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.

當(dāng)我的意思是你將無(wú)法控制"時(shí),我的意思是你創(chuàng)建的類(lèi)通常具有有限的存在空間,并且存在是眾所周知的.如果它是一個(gè)返回值并且有人試圖在不同的 AppDomain(或在不同的機(jī)器上)調(diào)用它,他們會(huì)得到一個(gè)錯(cuò)誤,并且可以說(shuō)不要那樣使用它".調(diào)用者知道他們必須將其轉(zhuǎn)換為可以序列化的類(lèi)型(通過(guò)包裝方法調(diào)用).但是,由于如果沒(méi)有被捕獲,異常就會(huì)冒泡到最頂端,它們可以超越您甚至不知道的 AppDomain 邊界.您在不同 AppDomain 中的 20 級(jí)自定義應(yīng)用程序異常可能是 Main() 報(bào)告的異常,并且在此過(guò)程中沒(méi)有任何東西可以將其轉(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))的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Is there a way to know if someone has bookmarked your website?(有沒(méi)有辦法知道是否有人為您的網(wǎng)站添加了書(shū)簽?)
Use of Different .Net Languages?(使用不同的 .Net 語(yǔ)言?)
Determining an #39;active#39; user count of an ASP.NET site(確定 ASP.NET 站點(diǎn)的“活動(dòng)用戶數(shù))
Best way to keep track of current online users(跟蹤當(dāng)前在線用戶的最佳方式)
Recommend an Open Source .NET Statistics Library(推薦一個(gè)開(kāi)源的.NET統(tǒng)計(jì)庫(kù))
Create a summary description of a schedule given a list of shifts(給定輪班列表,創(chuàng)建時(shí)間表的摘要描述)
主站蜘蛛池模板: 日韩成人免费av | 新超碰97| 国产一级片在线播放 | 免费精品| 日韩视频在线播放 | 夜夜爽99久久国产综合精品女不卡 | 日韩欧美字幕 | 狠狠亚洲| 久久com| 久久99精品久久久久久琪琪 | 日本高清aⅴ毛片免费 | 视频1区 | 一区二区在线免费观看 | 久久久123 | 日韩在线观看中文字幕 | 国产伦一区二区三区视频 | 久久精品视频一区二区三区 | 日韩国产精品一区二区三区 | 99精品视频一区二区三区 | 999免费观看视频 | 日本在线免费观看 | 国产精品国产三级国产aⅴ中文 | 国产精品久久精品 | 国产欧美一区二区三区在线看 | 爱高潮www亚洲精品 中文字幕免费视频 | 九九热精品视频 | 蜜桃视频在线观看免费视频网站www | www.国产| 在线黄av | 综合色久| 日韩在线视频一区二区三区 | 一级一片在线观看 | 九九久久在线看 | 国产不卡在线播放 | 一区二区三区小视频 | 国产成人短视频在线观看 | 超碰成人免费 | 欧美日韩国产高清 | 美人の美乳で授乳プレイ | av中文在线播放 | 国产欧美日韩二区 |