Using AxHost to host a non-GUI ActiveX DLL

K

K Kemp

Hello,

I'm trying to access an ActiveX DLL from my .NET CF 2.0 application. I
followed Alex Feinman's example for hosting an ActiveX control:

- I ran AxImp on the mobile version of the DLL I want to use
- I added this source code to my project and added a reference to the
ActiveX DLL
- I added Alex's HostingLibrary projecto to my solution.

When I run the app, it fails on the call into the ActiveX DLL with
"Unspecified Error" I turned on CF interop logging and it looks like
the HostingLibrary is trying to call UI-related methods on my ActiveX
dll. Is there a way to use a non-GUI ActiveX DLL? I'm trying to use
the Dbmlsync integration component of iAnywhere's Mobilink, FWIW.

Here's my managed call:

protected AxDbmlsyncGUI mSyncEngine;
mSyncEngine = new AxDbmlsyncGUI();
mSyncEngine.Run(mlCommand.ToString());

Here are the relevant portions of my interop log:

[no flags]
void DbmlsyncCOM.IDbmlsync::Run(DbmlsyncCOM.IDbmlsync , string );
HRESULT Run(IDbmlsync *(INTF_VAL) this, Unknown (nt=0x13)(STRING_BSTR)
);

[preservesig]
int OleSite::System.Windows.Forms.IOleControlSite.OnFocus(OleSite ,
int );
int (I4_VAL)
System.Windows.Forms.IOleControlSite.OnFocus(IOleControlSite
*(INTF_VAL) this, int (I4_VAL) );

[preservesig]
int
System.Windows.Forms.IOleWindow::GetWindow(System.Windows.Forms.IOleWindow
, out IntPtr );
int (I4_VAL) GetWindow(IOleWindow *(INTF_VAL) this, INT_PTR * (I_REF)
);

[no flags]
void
System.Windows.Forms.IOleInPlaceObject::SetObjectRects(System.Windows.Forms.IOleInPlaceObject
, System.Windows.Forms.COMRECT , System.Windows.Forms.COMRECT );
HRESULT SetObjectRects(IOleInPlaceObject *(INTF_VAL) this, COMRECT
(BLIT_FORMATTED_CLASS) , COMRECT (BLIT_FORMATTED_CLASS) );

[pinvokeimpl][preservesig]
int System.Windows.Forms.AxHost::SetWindowPos(IntPtr ,
SetWindowPosZOrder , int , int , int , int , SetWindowPosFlags );
int (I4_VAL) SetWindowPos(INT_PTR (I_VAL) , int (I4_VAL) , int (I4_VAL)
, int (I4_VAL) , int (I4_VAL) , int (I4_VAL) , int (I4_VAL) );

Thanks in advance!
 
A

Alex Feinman [MVP]

I haven't looked at Mobilink but presumably the only reason it is packaged
as ActiveX is to make it eVB and MFC-friendly. It is likely that you may be
able to instantiate and invoke this control without actually hosting it. To
do this, you could call directly into the classes and methods exposed by the
import library generated by tlbimp. If you want to you could send me an
email with more details
 
Top