성태의 닷넷 이야기
작은 글씨
큰 글씨
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] 한국어 로컬 모델 풀 파인튜닝 - LLM 바닥부터 만들기 (대형...
[정성태] 그러고 보니, 저도 노안이라서... 어느 순간부터 웹 브라우저 ...
[정성태] The case of the invalid handle erro...
[정성태] 해당 글을 잠시 읽어보니까, 그 글에 답이 잘 나오는군요. ^^...
[정성태] Stating the obvious about debugging...
[정성태] https://www.c-sharpcorner.com/artic...
[정성태] How can I detect if one of my helpe...
[정성태] 32비트 값을 64비트 레지스터에 넣을 때, 상위 32비트에 대...
[정성태] 본문에서 상위 8바이트의 16비트가 사용되지 않는 것을 볼 수 ...
[정성태] 한 번도 궁금한 적이 없었는데, If I mark my t...
글쓰기
제목
이름
암호
전자우편
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<TKey, TValue> 개체 직렬화</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='https://learn.microsoft.com/en-us/archive/blogs/mglehman/post-7-serializing-dictionarystringstring-tofrom-xml'>https://learn.microsoft.com/en-us/archive/blogs/mglehman/post-7-serializing-dictionarystringstring-tofrom-xml</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>
첨부파일
스팸 방지용 인증 번호
1506
(왼쪽의 숫자를 입력해야 합니다.)