성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] 그냥 RSS Reader 기능과 약간의 UI 편의성 때문에 사용...
[이종효] 오래된 소프트웨어는 보안 위협이 되기도 합니다. 혹시 어떤 기능...
[정성태] @Keystroke IEEE의 문서를 소개해 주시다니... +_...
[손민수 (Keystroke)] 괜히 듀얼채널 구성할 때 한번에 같은 제품 사라고 하는 것이 아...
[정성태] 전각(Full-width)/반각(Half-width) 기능을 토...
[정성태] Vector에 대한 내용은 없습니다. Vector가 닷넷 BCL...
[orion] 글 읽고 찾아보니 디자인 타임에는 InitializeCompon...
[orion] 연휴 전에 재현 프로젝트 올리자 생각해 놓고 여의치 않아서 못 ...
[정성태] 아래의 글에 정리했으니 참고하세요. C# - Typed D...
[정성태] 간단한 재현 프로젝트라도 있을까요? 저런 식으로 설명만 해...
글쓰기
제목
이름
암호
전자우편
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'>InstallUtil로 .NET 서비스 등록 시 오류 - Operation is not supported. (Exception from HRESULT: 0x80131515).</h1> <p> 아마도, 특정 시점의 .NET Framework 패치부터 적용되는 것 같은데요. 근래에, C#으로 만든 '윈도우 서비스' 유형의 응용 프로그램을 웹 서버에 올려 놓은 후 다운로드 받아 해당 파일에 대해 InstallUtil.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:\temp>C:\WINDOWS\Microsoft.NET\Framework\<span style='color: blue; font-weight: bold'>v4.0.30319\InstallUtil.exe</span> C:\temp\TestService.exe Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1 Copyright (c) Microsoft Corporation. All rights reserved. Exception occurred while initializing the installation: System.IO.FileLoadException: Could not load file or assembly 'file:///C:\temp\TestService.exe' or one of its dependencies. <span style='color: blue; font-weight: bold'>Operation is not supported. (Exception from HRESULT: 0x80131515).</span> </pre> <br /> 재미있는 것은, 해당 서비스 프로그램을 .NET 2.0의 InstallUtil.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:\temp>C:\WINDOWS\Microsoft.NET\Framework\<span style='color: blue; font-weight: bold'>v2.0.50727\InstallUtil.exe</span> C:\temp\TestService.exe Microsoft (R) .NET Framework Installation utility Version 2.0.50727.3053 Copyright (c) Microsoft Corporation. All rights reserved. Running a transacted installation. Beginning the Install phase of the installation. See the contents of the log file for the C:\temp\Jennifer4Service.exe assembly's progress. The file is located at C:\temp\TestService.InstallLog. Installing assembly 'C:\temp\TestService.exe'. Affected parameters are: logtoconsole = assemblypath = C:\temp\TestService.exe logfile = C:\temp\TestService.InstallLog Installing service TestService... Service TestService has been successfully installed. Creating EventLog source Jennifer4Service in log Application... The Install phase completed successfully, and the Commit phase is beginning. See the contents of the log file for the C:\temp\TestService.exe assembly's progress. The file is located at C:\temp\TestService.InstallLog. Committing assembly 'C:\temp\TestService.exe'. Affected parameters are: logtoconsole = assemblypath = C:\temp\TestService.exe logfile = C:\temp\TestService.InstallLog <span style='color: blue; font-weight: bold'>The Commit phase completed successfully.</span> The transacted install has completed. </pre> <br /> 그래도 이건 해결 방법이 아니죠! ^^ 검색을 해보니, 다행히 이에 대한 좀 더 자세한 정보가 나옵니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > HRESULT: 0x80131515 when running installutil to install a .NET Service ; <a target='tab' href='http://brianseekford.com/wordpress/?p=514'>http://brianseekford.com/wordpress/?p=514</a> </pre> <br /> 아하~~~ 문제의 원인은 결국 보안 강화였군요. 정리하면, 인터넷에서 다운로드 받는 파일의 속성 창을 보면,<br /> <br /> <img alt='unblock_file.png' src='/SysWebRes/bbs/unblock_file.png' /><br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > This file came from another computer and might be blocked to help protect this computer. </pre> <br /> 위와 같이 "Unblock"이라는 버튼이 제공되는데, 이를 통해 해제한 후에야 .NET 4.0의 InstallUtil.exe로 잘 설치가 되는 것입니다.<br /> <br /> <hr style='width: 50%' /><br /> <a name='ads'></a> <br /> 그런데, 이런 작업을 매번 사용자에게 시킨다는 것은 말이 안되죠! 그래서, 해제할 수 있는 방법을 프로그램적으로 제공해 주어야 하는데요. 기술적으로 보면, "block" 파일의 구현은 내부에 "Zone.Identifier"라는 ADS(Alternate Data Streams)를 설정한 것에 불과하기 때문에 이 부분만 삭제하는 프로그램이 있으면 됩니다.<br /> <br /> 이런 용도로 <a target='tab' href='https://learn.microsoft.com/en-us/sysinternals/downloads/streams'>Sysinternals의 streams 프로그램</a>을 사용할 수 있습니다. 실제로 streams 프로그램을 이용해 인터넷으로부터 다운로드 받은 파일을 검사해 보면 이런 출력 결과를 볼 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > D:\temp><span style='color: blue; font-weight: bold'>streams TestService.exe</span> Streams v1.56 - Enumerate alternate NTFS data streams Copyright (C) 1999-2007 Mark Russinovich Sysinternals - www.sysinternals.com D:\temp\TestService.exe: <span style='color: blue; font-weight: bold'>:Zone.Identifier:$DATA 26</span> </pre> <br /> streams로 삭제하려면 -d 옵션을 주면 되는데 주의해야 할 사항이 있다면, streams는 'block' 표시 뿐만 아니라 모든 ADS(Alternate Data Streams) 구역을 기본적으로 삭제하기 때문에 원치 않는 ADS 삭제도 있을 수 있습니다. (또한, streams는 재배포 불가능한 라이선스를 갖고 있기 때문에 사용자 프로그램과 함께 배포할 수 없습니다.)<br /> <br /> streams 프로그램 대신, 간단하게 프로그램을 만드는 것도 생각해 볼 수 있습니다. 다행히 코드도 다음과 같이 굉장히 간단합니다. ^^<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > int _tmain(int argc, _TCHAR* argv[]) { if (argc == 2) { wchar_t tempPath[MAX_PATH] = { 0 }; if (StringCchPrintf(tempPath, MAX_PATH, <span style='color: blue; font-weight: bold'>L"%s:Zone.Identifier"</span>, argv[1]) == S_OK) { ::DeleteFile(tempPath); } return 0; } return 1; } </pre> <br /> 참고로, Powershell 3.0부터는 Unblock-File이라는 cmdlet이 제공됩니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Unblock-File ; <a target='tab' href='https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/unblock-file'>https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/unblock-file</a> </pre> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1744
(왼쪽의 숫자를 입력해야 합니다.)