성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] 아래의 글을 보면, MoveWindow 하면 될 듯한데요. ^^...
[Tom Lee] 안녕하세요 올려주신 글 참고하여 WPF 어플리케이션 안에 Uni...
[정성태] A graphical depiction of the steps ...
[정성태] 질문을 주셔서 출판사 측에 문의를 했습니다. 약 한 달 정도 후...
[Thorondor
] @정성태 개인 블로그인데도 거의 커뮤니티 급 인 것 같아요. 요...
[정성태] Roll A Lisp In C - Reading ; https...
[정성태] Java - How to use the Foreign Funct...
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>WCF - A property with the name 'UriTemplateMatchResults' already exists.</h1> <p> WCF 호출 시 예외는 발생하지 않지만, Visual Studio에서 Debug 모드로 실행했을 때는 다음과 같이 예외가 발생할 때가 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > System.ArgumentException occurred HResult=0x80070057 Message=A property with the name 'UriTemplateMatchResults' already exists. at System.ServiceModel.Channels.MessageProperties.UpdateProperty(String name, Object value, Boolean mustNotExist) </pre> <br /> First-chance 예외 설정으로 인한 것인데요.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > First-Chance Exception ; <a target='tab' href='http://www.sysnet.pe.kr/2/0/510'>http://www.sysnet.pe.kr/2/0/510</a> </pre> <br /> 이 예외를 재현하는 방법은 간단합니다. 다음과 같이 WCF 서비스를 정의하고,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System.ServiceModel; using System.ServiceModel.Web; namespace WcfService1 { [ServiceContract] public interface IService1 { [WebGet(UriTemplate = "date/{value}", ResponseFormat = WebMessageFormat.Xml)] [OperationContract] string GetData(int value); } } namespace WcfService1 { public class Service1 : IService1 { public string GetData(int value) { return string.Format("You entered: {0}", value); } } } </pre> <br /> 이 서비스를 WebHttpBinding으로 호출하는 경우,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System; using System.ServiceModel; using System.ServiceModel.Description; using WcfServiceLibrary1; namespace ConsoleApp1 { class Program { static void Main(string[] args) { while (true) { Console.ReadLine(); string svcUrl = "http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary1/Service1/WebA"; WebHttpBinding webHttpBinding = new WebHttpBinding(); using (ChannelFactory<IService1> factory = new ChannelFactory<IService1>(webHttpBinding, new EndpointAddress(svcUrl))) { factory.Endpoint.Behaviors.Add(new WebHttpBehavior()); IService1 svc = factory.CreateChannel(); <span style='color: blue; font-weight: bold'>string text = svc.GetData("2012");</span> Console.WriteLine(text); } } } } } </pre> <br /> svc.GetData 호출 시 내부에서 try/catch로 먹힌 "System.ArgumentException" 예외가 발생합니다. 물론, 실제 운영 시에는 지장이 없지만 Visual Studio에서 디버깅으로 "System.ArgumentException" 예외가 thrown되는 것은 여간 귀찮은 일이 아닐 수 없습니다.<br /> <br /> 이 예외를 없애기 위해서는 관리자 권한으로 실행한 명령행에서 다음과 같이 vsdiag_regwcf 도구를 제거하면 됩니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C:\Windows\System32><span style='color: blue; font-weight: bold'>vsdiag_regwcf.exe -u</span> Microsoft (R) Visual Studio (R) Diagnostics WCF Registration tool - Version 15.0.26208.0 (C) Microsoft Corporation. All rights reserved. Command completed successfully. C:\Windows\System32> </pre> <br /> 그런데, 이 도구가 쓸만한 것이기도 합니다. 다음의 문서를 보면 그동안 WCF 호출 시 클라이언트와 서버 간에 자연스럽게 Step-into 디버깅을 마술처럼 연결해 주었던 것이 바로 이 도구였다는 것을 알 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Debugging WCF Services in Visual Studio 2008 ; <a target='tab' href='https://blogs.msdn.microsoft.com/greggm/2008/03/17/debugging-wcf-services-in-visual-studio-2008/'>https://blogs.msdn.microsoft.com/greggm/2008/03/17/debugging-wcf-services-in-visual-studio-2008/</a> </pre> <br /> 그러니 선택을 해야 합니다. System.ArgumentException 예외를 thrown에서 해제하던가, 아니면 WCF step-into 마술을 포기하던가.<br /> <br /> 참고로, vsdiag_regwcf.exe는 다음의 경로에 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\vsdiag_regwcf.exe </pre> <br /> (<a target='tab' href='http://www.sysnet.pe.kr/bbs/DownloadAttachment.aspx?fid=1143&boardid=331301885'>첨부 파일은 이 글의 예제 코드를 포함</a>합니다.)<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
8903
(왼쪽의 숫자를 입력해야 합니다.)