ActiveX in DLL

H

hufaunder

I have an ActiveX component that I want to use in a library that I am
writing. As a first test I used the ActiveX component in a windows
form application. Adding the component created:

Ax[ActiveXName].dll
[ActiveXName].dll

I can not call the functions in the ActiveX component. In the next
step I tried to use the ActiveX component in a class library. I simply
added a reference to the corresponding COM component. This this only
[ActiveXName].dll was created. I assume this is ok because the
Ax...dll is just wrapping the component in a control (which I don't
need).

Now I have the following code:

ActiveXClassName class = new ActiveXClassName; //Note there is no Ax
in front of the class
class.DoSomething();

The second command produces and error: "COMException was unhandled.
Catastrphic failure (Exception from HRESULT:
0x8000FFFF(E_UNEXPECTED))"

I then added the following after instantiating the class:

((System.ComponentModel.ISupportInitialize)(class)).BeginInit();

This produces the error: "Unable to cast COM object of type 'xxx' to
interface type 'System.ComponentModel.ISupportInitialize'. This
operation failed because the QueryInterface call on the COM component
for the interface with IID '{CF793A55-B9DD-30C2-A484-360AF143C228}'
failed due to the following error: No such interface supported
(Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."

So what do I need to do to use this ActiveX component in my class
library?

Thanks
 
P

Patrick Steele

I have an ActiveX component that I want to use in a library that I am
writing. As a first test I used the ActiveX component in a windows
form application. Adding the component created:

Ax[ActiveXName].dll
[ActiveXName].dll

This looks like an ActiveX control. Is that what it is -- or is it an
ActiveX DLL? Two different things.
I can not call the functions in the ActiveX component.

Can you clarify that some more?

In the next
step I tried to use the ActiveX component in a class library. I simply
added a reference to the corresponding COM component. This this only
[ActiveXName].dll was created. I assume this is ok because the
Ax...dll is just wrapping the component in a control (which I don't
need).

If I recall, you're going to have a difficult time using a wrapped
ActiveX control in a class library since an ActiveX control is usually
designed to be hosted on a windows form that has a standard windows
message pump running. Without that message pump, the ActiveX control
will not work properly inside a class library.
 
A

Alvin Bruney [MVP]

Have you registered the ActiveX object? You'll need to do so before it will
allow instantiation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top