Getting an handle on an out-of-process ActiveX

O

Oriane

Hi there,

Inside a .Net project, I want to get an handle on an executable (a.exe)
ActiveX component instance, that is get it as an object if it is running.

I'll try with this code:
object o =
System.Runtime.InteropServices.Marshal.GetActiveObject("StibilServControl.CStibilServControl");

Unfortunaltely, I'm told that this operation is not available (error +
$exception {" Operation not available (Exception de HRESULT : 0x800401E3
(MK_E_UNAVAILABLE))"} System.Exception
{System.Runtime.InteropServices.COMException}

Any idea ?

The problem is that I use this ActiveX component inside a Web Service and
that if I simply create an instance of this ActiveX in the Web service class
constructor, each call to one of the Web service method calls the
constructor of the Web service which in turn creates the ActiveX. So at the
end, I've got plenty of them when only one would be enough !

Best regards
 
S

Steven Cheng [MSFT]

Hi Philippe,

Some community member and I have replied you in the following thread:

#SUBJECT: Using an ActiveX in a Web service
NEWSGROUP: microsoft.public.dotnet.framework.aspnet

Is this thread the same issue with that thread? Based on that thread, I
think you've got the out-process COM component to created correctly in your
webservice code, correct?

For creating COM instance in .NET application(no matter in-process or
out-process), you can use the later minding approach to create the instance
via progid or clsid. Note that you need to use the
"Activator.CreateInstance" method rather than "Marshal.GetActiveObject"

==============
object obj =
Activator.CreateInstance(Type.GetTypeFromProgID("Some.Application"));

==============

Marshal.GetActiveObject is used to get an existing running instance of a
COM component(rather than creating a new one):

http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marsh
al.getactiveobject.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
O

Oriane

Hi Steven,
Steven Cheng said:
Hi Philippe,

Some community member and I have replied you in the following thread:

#SUBJECT: Using an ActiveX in a Web service
NEWSGROUP: microsoft.public.dotnet.framework.aspnet

Is this thread the same issue with that thread? Based on that thread, I
think you've got the out-process COM component to created correctly in
your
webservice code, correct? Yes.

For creating COM instance in .NET application(no matter in-process or
out-process), you can use the later minding approach to create the
instance
via progid or clsid. Note that you need to use the
"Activator.CreateInstance" method rather than "Marshal.GetActiveObject"
Yes if I wish to create it that's what I would write. But I don't want to
create it, since it is already running. I want an handle on a running
component (since it is an executable, I could have been created before). So
I don't really need a later binding approach, but I didn't find any method
in Activator to do what I want.

Thanks for your support.

Oriane
 
S

Steven Cheng [MSFT]

Thanks for your reply Oriane,

No problem. If you need any help in the future, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 

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