[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.interop

GetActiveObject on a Vista machine

Cindy M.

10/22/2007 1:55:00 PM

Hi all

Up until now, I've been able to use something like this to
pick up a running instance of an office application

xl = (Excel.Application)
System.Runtime.InteropServices.Marshal.GetActiveObject
("Excel.Application.12");
if (xl != null)
{ } /etc.

When I try running this on a Vista box, I get an error
message on the first line:

"Operation unavailable (Exception from HRESULT: 0x800401E3
(MK_E_UNAVAILABLE))"

All the KB articles talk about the application not (yet)
being available in the ROT. But the application has been
open and running for some time, which makes me think this
has something to do with Vista.

Is there a way to get this to work using .NET? (VBA is no
problem BTW)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/ci... (last update
Jun 17 2005)
http://www.wor...

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)

2 Answers

Willy Denoyette [MVP]

10/23/2007 7:57:00 AM

0

"Cindy M." <C.Meister-C@hispeed.ch> wrote in message
news:VA.00001008.01611b05@vistapc...
> Hi all
>
> Up until now, I've been able to use something like this to
> pick up a running instance of an office application
>
> xl = (Excel.Application)
> System.Runtime.InteropServices.Marshal.GetActiveObject
> ("Excel.Application.12");
> if (xl != null)
> { } /etc.
>
> When I try running this on a Vista box, I get an error
> message on the first line:
>
> "Operation unavailable (Exception from HRESULT: 0x800401E3
> (MK_E_UNAVAILABLE))"
>
> All the KB articles talk about the application not (yet)
> being available in the ROT. But the application has been
> open and running for some time, which makes me think this
> has something to do with Vista.
>
> Is there a way to get this to work using .NET? (VBA is no
> problem BTW)
>
> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/ci... (last update
> Jun 17 2005)
> http://www.wor...
>
> This reply is posted in the Newsgroup; please post any
> follow question or reply in the newsgroup and not by e-mail
> :-)
>



Are you sure your client (calling into an instance of Excel), runs with IL
"medium integrity"?
All office applications run with this IL, connection to the remote instance
will fail from a client running with an higher IL, (for instance when you
run as "administrator").

Willy.

Cindy M.

10/23/2007 12:56:00 PM

0

Hi Willy,

Thank you. What you describe would be the problem, then. Obviously, I have a
few things to catch up on. Can you recommend a good resource for learning how
to deal with this? For example, I was running the code in debug mode, from
VS2008, started as administrator. This is what "they" recommend for Vista, but
obviously that does have some drawbacks <sigh>

I'm trying to be a "good girl" and use Vista "as designed" (not turn off the
security). But I can see this could lead to some problems...

> > Up until now, I've been able to use something like this to
> > pick up a running instance of an office application
> >
> > xl = (Excel.Application)
> > System.Runtime.InteropServices.Marshal.GetActiveObject
> > ("Excel.Application.12");
> > if (xl != null)
> > { } /etc.
> >
> > When I try running this on a Vista box, I get an error
> > message on the first line:
> >
> > "Operation unavailable (Exception from HRESULT: 0x800401E3
> > (MK_E_UNAVAILABLE))"
> >
> > All the KB articles talk about the application not (yet)
> > being available in the ROT. But the application has been
> > open and running for some time, which makes me think this
> > has something to do with Vista.
> >
> > Is there a way to get this to work using .NET? (VBA is no
> > problem BTW)
> >
> > Cindy Meister
> > INTER-Solutions, Switzerland
> > http://homepage.swissonline.ch/ci... (last update
> > Jun 17 2005)
> > http://www.wor...
> >
> > This reply is posted in the Newsgroup; please post any
> > follow question or reply in the newsgroup and not by e-mail
> > :-)
> >
>
>
>
> Are you sure your client (calling into an instance of Excel), runs with IL
> "medium integrity"?
> All office applications run with this IL, connection to the remote instance
> will fail from a client running with an higher IL, (for instance when you
> run as "administrator").
>

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/ci... (last update Jun 17 2005)
http://www.wor...

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)