Windows Service accessing COM through Interop
From: Bunce (anonymous_at_discussions.microsoft.com)
Date: 06/09/04
- Next message: mjcast: "RE: ActiveX Control written in C# Socket problem"
- Previous message: Lars von Wedel: "Installer for Interop DLL"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 9 Jun 2004 05:30:26 -0700
Hi all - bit of a confusing one..
I'm trying to setup a windows service which interacts
with some mapping software running on the same machine,
which exposes a number of interfaces through COM.
The service is meant to fire off this software upon the
changing of a text file on the server and for this I'm
using the FileSystemWatcher component. No problem there,
the FSW event fires fine when its meant to..
The problem is interacting with COM. Basically the
service needs to get a reference to a list of currently
running mapping processes, and from within that, fire off
a custom command within that application. This is all
performed through the exposed COM events provided by the
mapping software.
Strange thing is, this all works perfectly when I tested
it though a Windows Forms Exe, but as soon as I port
identical code to a service, I get a 'Server Execution
Error' when trying to get a referce to the
running 'mapping' applications, using this code:
Dim apps as New ESRI.ArcObjects.Core.AppRot
* Approt is the method which provides a hook into the
running mapping applications
* ESRI.Arcobjects.Core namespace is actually a .Net
assembly provided by the software manufacturers
specifically for .Net interop, however I've also tried it
by setting a reference to the original COM dll, and
having VS create the interop. Boh methods work in an
Windows Forms EXE but not a service.
Anyway, so what I'm wondering is if there is an
issue 'communicating' with running COM processes from
a .Net service, whereas there's no issue communicating
from a .Net EXE?
I assume it's a threading or context issue, although I've
scoured the Net for info on this and as yet have come up
empty.. I've tried running the service as both an STA and
an MTA with no difference. I've also tried running the
service under the same 'user account' that was logged in
when the EXE worked successfully but 'no banana'. So I
don't think it's a permissions issue...
Any ideas? I'm just about out of them.. Wondering if I
need to use 'Marshaling' somehow but am unsure how to do
it.. If I can somehow get the 'service' to act or
perform the same as the Windows Forms Exe then it will
hopefully work..
Thanks in advance,
Andrew
- Next message: mjcast: "RE: ActiveX Control written in C# Socket problem"
- Previous message: Lars von Wedel: "Installer for Interop DLL"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|