성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Get Started with Milvus Vector DB i...
[정성태] cyberark/PipeViewer - A tool that...
[정성태] WinForms in a 64-Bit world – our st...
[정성태] 예제에서 SELECT_SQL도 내부적으로는 SqlCommand/...
[victor] SELECT_LINQ SELECT_SQL 같은 쿼리인...
[victor] 답변 갑사합니다. 예외(Exception)가 났습니다. ...
[정성태] 일단, 위의 방식대로 하면 예외(Exception) 없이 잘 동...
[정성태] Windows 10 (버전 1809)에 이런 기능이 ^^ 추가되...
[정성태] pde windbg extension ; https://lea...
[정성태] // GetEnumerator extensions for Ran...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
닷넷
.NET 3.0
.NET 3.5
.NET 4.0
COM 개체 관련
Win32
Vista
Windows 7
Windows 8
Windows 서버
데이터베이스
웹폼 코딩 규약
윈폼 코딩 규약
공통 코딩 규약
명령행
레지스트리
기타
부모글 보이기/감추기
내용
<div style='display: inline'> <div style='font-family: 맑은 고딕, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>Dictionary<,> 개체 직렬화</div><br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; width: 800px; background-color: #fbedbb; overflow-x: scroll; font-family: Consolas, Verdana;' > Post #7 ? Serializing Dictionary<string,string> to/from XML ; <a target='_tab' href='http://blogs.msdn.com/mglehman/archive/2009/11/09/post-7-serializing-dictionary-string-string-to-from-xml.aspx'>http://blogs.msdn.com/mglehman/archive/2009/11/09/post-7-serializing-dictionary-string-string-to-from-xml.aspx</a> </pre> <br /> 오호... Dictionary<,> 타입이 XmlSerializer 에서는 예외가 나더니만, DataContractSerializer 로는 직렬화가 잘 되는군요.<br /> <br /> 코드가 간단하니 아래에 실어봅니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; width: 800px; background-color: #fbedbb; overflow-x: scroll; font-family: Consolas, Verdana;' > static void Main(string[] args) { Dictionary<string, string> dict = new Dictionary<string, string>(); dict.Add("test", "test1"); MemoryStream ms = new MemoryStream(); XmlWriter writer = XmlWriter.Create(ms); // 예외 발생 // XmlSerializer xs = new XmlSerializer(typeof(Dictionary<string, string>)); // xs.Serialize(ms, dict); <b style='COLOR: blue'>DataContractSerializer dcs</b> = new DataContractSerializer(typeof(Dictionary<string, string>)); dcs.WriteObject(writer, dict); writer.Close(); ms.Position = 0; Dictionary<string, string> dict2 = dcs.ReadObject(ms) as Dictionary<string, string>; } </pre> <br /><br /><hr /><span style='color: Maroon'>[이 토픽에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1343
(왼쪽의 숫자를 입력해야 합니다.)