久久久久久久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?

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

Why are exceptions different than other classes in this regard?

推薦答案

因?yàn)槟漠惓?赡苄枰诓煌?AppDomain 之間進(jìn)行編組,如果它們不能(正確)序列化,您將丟失寶貴的調(diào)試信息.與其他類不同,您無(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)建的類通常具有有限的存在空間,并且存在是眾所周知的.如果它是一個(gè)返回值并且有人試圖在不同的 AppDomain(或在不同的機(jī)器上)調(diào)用它,他們會(huì)得到一個(gè)錯(cuò)誤,并且可以說(shuō)不要那樣使用它".調(diào)用者知道他們必須將其轉(zhuǎn)換為可以序列化的類型(通過(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)站添加了書簽?)
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è)開源的.NET統(tǒng)計(jì)庫(kù))
Create a summary description of a schedule given a list of shifts(給定輪班列表,創(chuàng)建時(shí)間表的摘要描述)
主站蜘蛛池模板: 黄在线 | 天堂网中文字幕在线观看 | 欧美一区二区三区大片 | 91中文视频 | 久久久久久亚洲欧洲 | 日本在线观看视频 | cao视频| 黄网站涩免费蜜桃网站 | 国产9999精品| 九九热在线视频 | 日本韩国电影免费观看 | 欧美成视频 | 久久久爽爽爽美女图片 | 日韩高清国产一区在线 | 成人1区2区| 国产精品日韩欧美一区二区三区 | 欧美日韩国产一区二区三区 | 国产精品99 | 久久一区精品 | 欧美不卡网站 | 国产精品伦理一区 | 99免费视频 | 久久久久久国模大尺度人体 | 综合一区二区三区 | 日韩欧美在线观看 | 国产精品国产精品国产专区不蜜 | 欧美综合久久 | 亚洲综合网站 | 国产高清精品一区二区三区 | 亚洲精品乱码 | 综合天天久久 | 欧美精品a∨在线观看不卡 国产精品久久国产精品 | 成人自拍视频 | 色就是色欧美 | 日韩欧美国产成人一区二区 | 黄视频欧美| 国产黄色大片在线观看 | 国产精品99久久久久久www | 精品久久久久久久久久久院品网 | 国产91丝袜在线播放 | 国产精品免费一区二区三区四区 |