473,327 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

GetObject function in windows services

Hello,

I posted yesterday the same problem, but now I want to be
more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of
course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application
is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei

Jul 21 '05 #1
5 6319
"Andrei" <pr**********@hotmail.com> wrote in news:003b01c3770f$d95a89b0
$a*******@phx.gbl:
Hello,

I posted yesterday the same problem, but now I want to be
more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of
course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application
is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei


I'm unclear as to what is working and what is not for you? Are you
saying GetObject() works for getting the reference to the application,
but not other classes inside the application? Getobject() is only for
getting a reference to the application. You don't use it to get a
Document class instance. instead use the Documents property of the
Application instance!

Here is the code I use to get a reference to an application object in
AutoCAD. This should be very similar for a Word application:

mcadApplication = (AutoCAD.AcadApplicationClass)
Marshal.GetActiveObject("AutoCAD.Application");

It works similarly to GetObject.

--
Michael Lang, MCSD

Jul 21 '05 #2
Hi Michael,

Thank you for your reply. I will try to be more clear.

GetObject is returning me an error when I try to get a
reference to the Word application. But this is happening
only in windows services, in a standard windows
application I have no error.

CreateObject is working fine in both cases (windows
services or windows applications)

My question is why I cannot use GetObject in a windows
sevice?

Thank you,
Andrei

-----Original Message-----
"Andrei" <pr**********@hotmail.com> wrote in news:003b01c3770f$d95a89b0$a*******@phx.gbl:
Hello,

I posted yesterday the same problem, but now I want to be more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei
I'm unclear as to what is working and what is not for

you? Are yousaying GetObject() works for getting the reference to the application,but not other classes inside the application? Getobject () is only forgetting a reference to the application. You don't use it to get aDocument class instance. instead use the Documents property of theApplication instance!

Here is the code I use to get a reference to an application object inAutoCAD. This should be very similar for a Word application:
mcadApplication = (AutoCAD.AcadApplicationClass)
Marshal.GetActiveObject("AutoCAD.Application");

It works similarly to GetObject.

--
Michael Lang, MCSD

.

Jul 21 '05 #3
Hi Michael,

I have tried using Marshal.GetActiveObject instead of
GetObject as you suggested. I got an error : "Operation
unavailable"

Andrei,
-----Original Message-----
"Andrei" <pr**********@hotmail.com> wrote in news:003b01c3770f$d95a89b0$a*******@phx.gbl:
Hello,

I posted yesterday the same problem, but now I want to be more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei
I'm unclear as to what is working and what is not for

you? Are yousaying GetObject() works for getting the reference to the application,but not other classes inside the application? Getobject () is only forgetting a reference to the application. You don't use it to get aDocument class instance. instead use the Documents property of theApplication instance!

Here is the code I use to get a reference to an application object inAutoCAD. This should be very similar for a Word application:
mcadApplication = (AutoCAD.AcadApplicationClass)
Marshal.GetActiveObject("AutoCAD.Application");

It works similarly to GetObject.

--
Michael Lang, MCSD

.

Jul 21 '05 #4
"Andrei" <pr**********@hotmail.com> wrote in news:042b01c37716$38e01020
$a*******@phx.gbl:
Hi Michael,

I have tried using Marshal.GetActiveObject instead of
GetObject as you suggested. I got an error : "Operation
unavailable"

Andrei,


Sorry, I've never made a Windows Service. I don't know why it would work
on Windows Forms and not a Windows Service?

--
Michael Lang, MCSD

Jul 21 '05 #5
This is the kind of thing that smells of a security issue. Your Service is
probably running with the LocalSystem account in its own Windowstation, but
trying to drive a Word application that may be installed for a different
user, or that can't access the interactive user's desktop.

What happens if you run the Service under your account name/password?
--
Phil Wilson [MVP Windows Installer]

"Andrei" <pr**********@hotmail.com> wrote in message
news:00****************************@phx.gbl...
Hello,

I posted yesterday the same problem, but now I want to be
more specific about it.

My intention is to create a windows service to process
some Word documents. If I use CreateObject to create a
reference to a Word object everything is working fine.

If I use GetObject to get a reference to Word object (of
course that Word applicaton is started) I get an error
("Cannot create ActiveX component")

It is like my service cannot detect that Word application
is started.

I want to say that GetObject is working fine from a
standard Windows application.

Thank you,
Andrei

Jul 21 '05 #6

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

Similar topics

2
by: Gerry | last post by:
I have a developer here with a website running with only "Windows Integrated Authentication" set on a Windows 2000 member server that uses GetObject to get a user's group membership in the domain....
2
by: CJM | last post by:
I'm building an ASP app that uses Windows Authentication (IWA). I have an authentication routine that assesses if & how the user can use the application (see code snippet below). Users of a...
2
by: Andrei Prodan | last post by:
Hi everyone, I have a small piece of code which uses GetObject function and it is working fine in a windows application developed under .NET In a windows service application, the GetObject...
4
by: bic | last post by:
When porting my Windows app to asp.net I get an System.Exception: Cannot create ActiveX component. What function can I use instead? Thanks for your comments. -- bic
3
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet...
5
by: Yong Yu | last post by:
Dear All, I have to move my VB code to C#. But I have no idea on the GetObject method in Vb. ----------------------------------------- Set dom = GetObject("WinNT://" & domain)...
3
by: perspolis | last post by:
Is there a method like GetObject in vb to get an instance of current object runnig??
5
by: Andrei | last post by:
Hello, I posted yesterday the same problem, but now I want to be more specific about it. My intention is to create a windows service to process some Word documents. If I use CreateObject to...
3
by: aydeejay | last post by:
I'm trying to troubleshoot an issue where users are not able to bind with LDAP via "GetObject" through our ASP Classic Intranet if they stay logged in overnight (beyond their allowed login hours). ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.