# HwpAutomation과 HwpObject의 차이는?

**URL:** <https://forum.developer.hancom.com/t/hwpautomation-hwpobject/62>\
**Category:** 한글 컨트롤\
**Created:** [10월 14, 2021, 5:55오전 UTC](https://forum.developer.hancom.com/t/hwpautomation-hwpobject/62 "2021-10-14T05:55:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dev.community](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.developer.hancom.com/dev.community/32/488_2.png) [@dev.community](https://forum.developer.hancom.com/u/dev.community)\
**Post date:** [10월 14, 2021, 5:55오전 UTC](https://forum.developer.hancom.com/t/hwpautomation-hwpobject/62/1 "2021-10-14T05:55:15Z")

</div>

_(예전 커뮤니티(2016-2020) 사이트에서 옮겨온 글입니다: [번호 25](https://www.hancom.com/board/devcommView.do?board_seq=48&artcl_seq=6517))_

작성자: gongdo  
날짜: 2017-01-12

* * *

안녕하세요, 하루 걸러 또 질문입니다.

가능하면 UI가 없이 콘솔 프로그램으로 COM 오브젝트에 접근하고 싶습니다.

두 종류의 tlb가 제공되는데 둘 다 각각 다른 현상으로 사용할 수 없습니다.

- Bin\HwpObject.tlb

- Bin\HwpAutomation.tlb

C# Console App에서 두 라이브러리를 Add Reference로 넣고 다음과 같이 코딩하였습니다.

* * *

```auto
//var hwp = new HwpObjectLib.HwpObject(); // HwpObject.tlb를 사용한 경우. 아래 메서드들은 동일.
var hwp = new HwpAutomationAppLib.HwpAutomation();
hwp.RegisterModule("FilePathCheckDLL", "FilePathCheckerModuleExample");
hwp.Open(@"D:\Temp\a.hwp", null, null);
hwp.SaveAs(@"D:\Temp\a.hml", "HWPML2X", null);？

```

* * *

이 때 HwpObject는 생성 단계에서 다음과 같은 예외가 발생합니다.

* * *

Unable to cast COM object of type ‘System.\_\_ComObject’ to interface type ‘HwpObjectLib.HwpObject’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{5E6A8276-CF1C-42B8-BCED-319548B02AF6}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E\_NOINTERFACE)).

* * *

다른 HwpAutomation은 Open 메서드를 호출 할 때 다음과 같은 예외가 발생합니다.

* * *

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

* * *

~~만약 C# WinForm으로 동일한 코드를 작성하면,~~

~~- HwpObject는 동일한 오류 발생~~

~~- HwpAutomation은 정상작동~~

~~합니다.~~

-수정-

방금 테스트해보니 WinForm에 OCX컨트롤을 올려놓지 않으면 HwpAutomation도 작동하지 않았습니다.

1. 이 두 tlb의 차이는 무엇인가요?

2. 부모 윈도(hwnd)가 없는 콘솔 프로그램에서 COM 오브젝트로 접근할 수 있을까요?

감사합니다.

#### 댓글

##### yhjung (2017.01.19)

기본적으로 오토메이션사용 시 HwpObjectLib 를 쓰셔야 좋습니다.  
C#에서 활성화는 아래 두줄만 입력되어도 정상적으로 나옵니다

```auto
using HwpObjectLib;
HwpObject myHwp = new HwpObject();

```
