성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Reordering on an Alpha processor ;...
[정성태] 공유 감사합니다. ^^ 참고로, WPF에서 WindowsF...
[Tom Lee] 답변 감사합니다. 나름의 해결책 연구해보고 여기에도 공유해봅니다...
[정성태] 아래의 글을 보면, 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...
글쓰기
제목
이름
암호
전자우편
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'>해당 어셈블리가 Debug 빌드인지, Release 빌드인지 알아내는 방법</h1> <p> 국내는 어떤지 모르겠지만, 해외의 경우에는 '서비스 중인 DLL'이 Debug 빌드된 것인지, Release 빌드된 것인지를 민감하게 여기는 경우가 있는 것 같습니다. 필요 없이 성능에 손해되는 DLL로 서비스할 이유는 없으니까요.<br /> <br /> 검색을 해보면, 생각보다 쉽게 방법을 찾을 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > How to tell if a .NET application was compiled in DEBUG or RELEASE mode? ; <a target='tab' href='http://stackoverflow.com/questions/194616/how-to-tell-if-a-net-application-was-compiled-in-debug-or-release-mode'>http://stackoverflow.com/questions/194616/how-to-tell-if-a-net-application-was-compiled-in-debug-or-release-mode</a> </pre> <br /> 정리해 보면, 결국 컴파일 된 DLL이 Debug인지 Release인지는 Debuggable이라는 특성에 지정된 값으로만 확인을 할 수 있습니다. 아래는 .NET Reflector로 확인해 본 것입니다.<br /> <br /> <img alt='debug_or_release_1.png' src='/SysWebRes/bbs/debug_or_release_1.png' /><br /> <br /> 답이 모두 나왔군요. 즉, 해당 DLL을 로드한 다음 assembly 레벨에 지정된 Debuggable 특성을 살펴보면 되는 것입니다. 그런데, 어떤 값을 봐야 하는 걸까요?<br /> <br /> 일단, Visual Studio에서 Debug 모드로 빌드한 DLL은 다음와 같은 특성을 포함하고 있었습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.EnableEditAndContinue | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.Default)] </pre> <br /> 반면, Release 모드로 빌드한 경우에는 결과가 다릅니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] </pre> <br /> 특성들을 보건데, 당연히 "DebuggableAttribute.DebuggingModes.DisableOptimizations" 옵션값이 중요합니다. 실제로, DebuggableAttribute 타입에 정의된 IsJITOptimizerDisabled 공용 속성도 다음과 같이 마이크로소프트에 의해서 코드 작성이 된 것을 볼 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > public bool IsJITOptimizerDisabled { get { return ((this.m_debuggingModes & <span style='color: blue; font-weight: bold'>DebuggingModes.DisableOptimizations</span>) != DebuggingModes.None); } } </pre> <br /> <span style='text-decoration: line-through'> 아래는, (DLL을 잠그지 않는) ReflectionOnly 버전으로 작성한 코드입니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > static void Main(string[] args) { Assembly asm = Assembly.ReflectionOnlyLoadFrom("ClassLibrary1.dll"); foreach (var attr in asm.GetCustomAttributesData()) { if (attr.Constructor.ReflectedType == <span style='color: blue; font-weight: bold'>typeof(DebuggableAttribute)</span>) { foreach (var arg in attr.ConstructorArguments) { if (arg.ArgumentType == <span style='color: blue; font-weight: bold'>typeof(System.Diagnostics.DebuggableAttribute.DebuggingModes)</span>) { System.Diagnostics.DebuggableAttribute.DebuggingModes mode = (System.Diagnostics.DebuggableAttribute.DebuggingModes)arg.Value; bool isDebug = <span style='color: blue; font-weight: bold'>mode.HasFlag(System.Diagnostics.DebuggableAttribute.DebuggingModes.DisableOptimizations)</span>; Console.WriteLine(asm.FullName + " ==> " + isDebug); } } } } } </pre> <br /> </span> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1345
(왼쪽의 숫자를 입력해야 합니다.)