[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Getting an handle on an out-of-process ActiveX

Oriane

7/24/2008 4:21:00 PM

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



4 Answers

stcheng

7/25/2008 3:20:00 AM

0

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.interopserv...
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:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
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/de....
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Oriane" <oriane@noemail.noemail>
>Subject: Getting an handle on an out-of-process ActiveX
>Date: Thu, 24 Jul 2008 18:21:19 +0200

>
>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.C
StibilServControl");
>
>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
>
>
>
>

Oriane

7/25/2008 7:17:00 AM

0

Hi Steven,
"Steven Cheng [MSFT]" <stcheng@online.microsoft.com> a écrit dans le message
de news:i0uFlVg7IHA.4056@TK2MSFTNGHUB02.phx.gbl...
> 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

Oriane

7/25/2008 8:31:00 AM

0

Hi Steven,

Happily, I don't need anymore this functionality :-).

Oriane

stcheng

7/28/2008 2:51:00 AM

0

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:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: "Oriane" <oriane@noemail.noemail>
>References: <917F590D-0231-40D8-BA72-467B6AF3B089@microsoft.com>
<i0uFlVg7IHA.4056@TK2MSFTNGHUB02.phx.gbl>
>In-Reply-To: <i0uFlVg7IHA.4056@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: Getting an handle on an out-of-process ActiveX
>Date: Fri, 25 Jul 2008 10:31:13 +0200

>
>Hi Steven,
>
>Happily, I don't need anymore this functionality :-).
>
>Oriane
>