473,732 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ActiveX in DLL

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:

ActiveXClassNam e class = new ActiveXClassNam e; //Note there is no Ax
in front of the class
class.DoSomethi ng();

The second command produces and error: "COMExcepti on was unhandled.
Catastrphic failure (Exception from HRESULT:
0x8000FFFF(E_UN EXPECTED))"

I then added the following after instantiating the class:

((System.Compon entModel.ISuppo rtInitialize)(c lass)).BeginIni t();

This produces the error: "Unable to cast COM object of type 'xxx' to
interface type 'System.Compone ntModel.ISuppor tInitialize'. 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

Feb 2 '07 #1
6 8077
In article <11************ **********@v33g 2000cwv.googleg roups.com>,
hu*******@yahoo .com says...
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.
--
Patrick Steele
http://weblogs.asp.net/psteele
Feb 2 '07 #2
On Feb 2, 6:17 am, Patrick Steele <patr...@mvps.o rgwrote:
In article <1170402719.020 557.302...@v33g 2000cwv.googleg roups.com>,
hufaun...@yahoo .com says...
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.

--
Patrick Steelehttp://weblogs.asp.net/psteele
Patrick,

Thanks a lot for the response. I am not sure what the difference is
between an ActiveX control and ActiveX DLL. One sound like a GUI
component and the other a plain DLL but aren't all ActiveX components
a GUI component?

In any case, the file extension off the control is .ocx. Also I can
drag that control onto a window. It has no functionality in a window,
though. It seems to me they just did it this way to make it easier for
the programmer who wants to use the control.

Hm, it would be too bad if an ActiveX control (one with a GUI) could
not be used in a plain class library. Can somebody confirm that?

Thanks

Feb 2 '07 #3
<hu*******@yaho o.comwrote in message
news:11******** **************@ q2g2000cwa.goog legroups.com...
On Feb 2, 6:17 am, Patrick Steele <patr...@mvps.o rgwrote:
>In article <1170402719.020 557.302...@v33g 2000cwv.googleg roups.com>,
hufaun...@yaho o.com says...
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.

--
Patrick Steelehttp://weblogs.asp.net/psteele

Patrick,

Thanks a lot for the response. I am not sure what the difference is
between an ActiveX control and ActiveX DLL. One sound like a GUI
component and the other a plain DLL but aren't all ActiveX components
a GUI component?

In any case, the file extension off the control is .ocx. Also I can
drag that control onto a window. It has no functionality in a window,
though. It seems to me they just did it this way to make it easier for
the programmer who wants to use the control.

Hm, it would be too bad if an ActiveX control (one with a GUI) could
not be used in a plain class library. Can somebody confirm that?

Thanks

An ocx is an ActiveX dll, which normally contains a number of ActiveX controls. ActiveX
controls must be hosted and need an Single Threaded Apartment thread to run in.
In your case, you need to set a reference to the ocx like you did initially, and you need to
initialize the thread to Join an STA, that is, you need to set the ApartmentState of the
thread to STA before starting the thread.

Willy.

Feb 2 '07 #4
On Feb 2, 8:24 am, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
<hufaun...@yaho o.comwrote in message

news:11******** **************@ q2g2000cwa.goog legroups.com...


On Feb 2, 6:17 am, Patrick Steele <patr...@mvps.o rgwrote:
In article <1170402719.020 557.302...@v33g 2000cwv.googleg roups.com>,
hufaun...@yahoo .com says...
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.
--
Patrick Steelehttp://weblogs.asp.net/psteele
Patrick,
Thanks a lot for the response. I am not sure what the difference is
between an ActiveX control and ActiveX DLL. One sound like a GUI
component and the other a plain DLL but aren't all ActiveX components
a GUI component?
In any case, the file extension off the control is .ocx. Also I can
drag that control onto a window. It has no functionality in a window,
though. It seems to me they just did it this way to make it easier for
the programmer who wants to use the control.
Hm, it would be too bad if an ActiveX control (one with a GUI) could
not be used in a plain class library. Can somebody confirm that?
Thanks

An ocx is an ActiveX dll, which normally contains a number of ActiveX controls. ActiveX
controls must be hosted and need an Single Threaded Apartment thread to run in.
In your case, you need to set a reference to the ocx like you did initially, and you need to
initialize the thread to Join an STA, that is, you need to set the ApartmentState of the
thread to STA before starting the thread.

Willy.- Hide quoted text -

- Show quoted text -
Excuse my ignorence but I am new to this ActiveX stuff and despite
reading up it I don't really have a handle on it yet.

Just for reference, I have an interface IMyInterface and several class
libraries that implement this interface (i.e. no GUI). One of these
class libraries needs to call functions from an ActiveX control (ocx).
This ActiveX control has a GUI who's only purpose probably is to
easily create a message handler. My class library then can be used
from a Windows Form, a console application, etc.

I am able to use this ActiveX control in a Windows Form application
but not in my class library. How would I do that?

Currently, I only reference [ActiveXName].dll in my class library. I
wonder if I would need to reference Ax[ActiveXName].dll instead and
use the class in that dll. I assume that would create a thread for me.
I was not successful in doing that either, though.

Thanks

Feb 2 '07 #5
<hu*******@yaho o.comwrote in message
news:11******** **************@ j27g2000cwj.goo glegroups.com.. .
On Feb 2, 8:24 am, "Willy Denoyette [MVP]"
<willy.denoye.. .@telenet.bewro te:
><hufaun...@yah oo.comwrote in message

news:11******* *************** @q2g2000cwa.goo glegroups.com.. .


On Feb 2, 6:17 am, Patrick Steele <patr...@mvps.o rgwrote:
In article <1170402719.020 557.302...@v33g 2000cwv.googleg roups.com>,
hufaun...@yaho o.com says...
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.
>--
Patrick Steelehttp://weblogs.asp.net/psteele
Patrick,
Thanks a lot for the response. I am not sure what the difference is
between an ActiveX control and ActiveX DLL. One sound like a GUI
component and the other a plain DLL but aren't all ActiveX components
a GUI component?
In any case, the file extension off the control is .ocx. Also I can
drag that control onto a window. It has no functionality in a window,
though. It seems to me they just did it this way to make it easier for
the programmer who wants to use the control.
Hm, it would be too bad if an ActiveX control (one with a GUI) could
not be used in a plain class library. Can somebody confirm that?
Thanks

An ocx is an ActiveX dll, which normally contains a number of ActiveX controls. ActiveX
controls must be hosted and need an Single Threaded Apartment thread to run in.
In your case, you need to set a reference to the ocx like you did initially, and you need
to
initialize the thread to Join an STA, that is, you need to set the ApartmentState of the
thread to STA before starting the thread.

Willy.- Hide quoted text -

- Show quoted text -

Excuse my ignorence but I am new to this ActiveX stuff and despite
reading up it I don't really have a handle on it yet.

Just for reference, I have an interface IMyInterface and several class
libraries that implement this interface (i.e. no GUI). One of these
class libraries needs to call functions from an ActiveX control (ocx).
This ActiveX control has a GUI who's only purpose probably is to
easily create a message handler. My class library then can be used
from a Windows Form, a console application, etc.

I am able to use this ActiveX control in a Windows Form application
but not in my class library. How would I do that?

Currently, I only reference [ActiveXName].dll in my class library. I
wonder if I would need to reference Ax[ActiveXName].dll instead and
use the class in that dll. I assume that would create a thread for me.
I was not successful in doing that either, though.

Thanks

The fact that you use the instance of the activeX control from a class library is
irrelevant, point is, that the class that holds the ActiveX control reference and calls it's
methods (and possibly sink it's events), needs a (1)pumping (2)STA thread to run in. You
absolutely need to pump the ActiveX controls message queue, failing to pump will block the
Finalizer thread whenever he needs to run the finalizer of the RCW.
The most obvious thread for this is the UI thread (an ActiveX control natural habitat), as
it fulfills both conditions. If you do want to use your class library from a non-UI
application, you'll have to create a *pumping* STA thread in your class library. But now you
have to answer the next question - how are the users of this class going to call the class
methods?

Willy.

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

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
<hu*******@yaho o.comwrote in message
news:11******** **************@ v33g2000cwv.goo glegroups.com.. .
>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:

ActiveXClassNam e class = new ActiveXClassNam e; //Note there is no Ax
in front of the class
class.DoSomethi ng();

The second command produces and error: "COMExcepti on was unhandled.
Catastrphic failure (Exception from HRESULT:
0x8000FFFF(E_UN EXPECTED))"

I then added the following after instantiating the class:

((System.Compon entModel.ISuppo rtInitialize)(c lass)).BeginIni t();

This produces the error: "Unable to cast COM object of type 'xxx' to
interface type 'System.Compone ntModel.ISuppor tInitialize'. 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

Feb 4 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4564
by: AnalogKid | last post by:
Short question: What's the difference between SingleUse and MultiUse ? Long question: I've been writing some sample code to see how different Instancing values and threading models work. I tried all main combinations of Instancing (Multiuse/Singleuse) and of Threading models (per object/pool). Here's what I found: MultiUse - Thread per Object
1
5994
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is a ocx developed my me use vc6,this ocx works fine in wxpython. but you can see i only change this ocx with a new DICOM ocx and set up eventClass,
2
7574
by: Fie Fie Niles | last post by:
This one XP machine (with IE 6) is having a problem viewing any ActiveX controls (created on VB6) on the Internet Explorer browser. I put the same ActiveX control in a VB program, and when I run the VB program on that same machine, I can view the ActiveX control fine. He is using Citrix. The same ActiveX controls can be viewed on other machines. When trying to view 1 of the ActiveX control, he got an error "Visual Basic Run-time redist...
6
2588
by: Pippen | last post by:
I'm getting a little confused about what is supported in MS-SQL ActiveX and what is Visual Basic and what is VBScript. Can someone please point me to a website, recommend a book or if I've missed it where in the MS-SQL help that deals with the ActiveX supported in SQL. I'm not looking to do web pages ASP, ect. I'm looking to use the ActiveX as add on funtionality to support the Stored Procs I write. Thanks, -p
12
2591
by: A.M. | last post by:
Hi at all, how can I do to insert into a HTML page a file .txt stored in the same directory of the server where is the html file that must display the text file.txt? Thank you very much P.Pietro
0
7126
by: Ike | last post by:
I have an Activex Control created in VB6, which, displays no problem on any machine I have, but, on some machines of others, it does not. All machines are running either XP or Windows 2000, and all are running MSIE6.x, woth security settings set to display this control. For the life of me, I cannot figure out how such a simple control can be so sporadic in it;s showing on a page. It always downloads - it just doesn't always show. I'm...
18
8430
by: DartmanX | last post by:
Is there a simple way to determine if someone using Internet Explorer has completely disabled ActiveX controls? Jason
7
4396
by: Jarod_24 | last post by:
I just downloaded a activex control that was written in C# and tried to view it on my PDA's Internet Explorer. At my regular PC it displayed just fine, but nothing showed up on the pda. Do ActiveX controls that are to be used by a pda need to be written in the ..net compact framework, or am i missing something else here? i have a HP iPaq 2490 with Windows Mobile Premium installed While i'm at it; does a activex control allow you to...
4
6789
by: Wilfried Mestdagh | last post by:
Hi, I have a C# application (VS2005) with Microsoft Mappoint activeX control on a form. At a certain moment I want to create a second one temporary in code. This seems not to work, when I try to access it I have an InvalidActiveXState Exception. I cannot find mutch on the web about this Invalid State of a component except that it is invalid (what the Exception already describe). So I hope someone here knows ?
0
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9447
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9235
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.