.NET 2.0 になり、アンマネージドとの相互変換時の変数型の定義を明確にしないと、InvalidVariant MDA メッセージが投げられるようになった。動作確認した定義は以下の通り。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Runtime.InteropServices;
using MSHTML;
namespace net.tilfin
{
[ComImport(),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
GuidAttribute("bd3f23c0-d43e-11cf-893b-00aa00bdce1a")]
public interface IDocHostUIHandler
{
[PreserveSig]
uint ShowContextMenu(
uint dwID,
ref tagPOINT ppt,
[MarshalAs(UnmanagedType.IUnknown)] object pcmdtReserved,
[MarshalAs(UnmanagedType.IDispatch)] object pdispReserved
);
void GetHostInfo(ref DOCHOSTUIINFO pInfo);
void ShowUI(uint dwID,
[In, MarshalAs(UnmanagedType.Interface)] IOleInPlaceActiveObject activeObject,
[In, MarshalAs(UnmanagedType.Interface)] IOleCommandTarget commandTarget,
[In, MarshalAs(UnmanagedType.Interface)] IOleInPlaceFrame frame,
[In, MarshalAs(UnmanagedType.Interface)] Object doc);
void HideUI();
void UpdateUI();
void EnableModeless(int fEnable);
void OnDocWindowActivate(int fActivate);
void OnFrameWindowActivate(int fActivate);
void ResizeBorder(ref tagRECT prcBorder, int pUIWindow, int fFrameWindow);
\[PreserveSig\]
uint TranslateAccelerator(ref tagMSG lpMsg, ref Guid pguidCmdGroup, uint nCmdID);
void GetOptionKeyPath(\[MarshalAs(UnmanagedType.BStr)\] ref string pchKey, uint dw);
void GetDropTarget(
\[MarshalAs(UnmanagedType.Interface)\] IDropTarget pDropTarget,
\[Out, MarshalAs(UnmanagedType.Interface)\] out IDropTarget ppDropTarget);
void GetExternal(\[MarshalAs(UnmanagedType.IDispatch)\] out object ppDispatch);
\[PreserveSig\]
uint TranslateUrl(
uint dwTranslate,
\[MarshalAs(UnmanagedType.BStr)\] string pchURLIn,
\[MarshalAs(UnmanagedType.BStr)\] ref string ppchURLOut
);
System.Windows.Forms.IDataObject FilterDataObject(System.Windows.Forms.IDataObject pDO);
}
}