I'm having trouble creating and consuming a serviced component.
I started with a blank solution, added a class library, and created a
serviced component class. So far so good. Everything works. Then, I create
a strong name, and use gacutil to install it into the global assembly cash,
and also regsvcs. Everything is fine, and I see the component in my
Component Service snap-in.
Now, I need a client. I add a Windows Forms application to the solution. I
suppose I'll need a reference to the serviced component. But...do I just add
a reference to the project, or to the serviced component now listed under the
COM tab?
I try the COM tab. "A reference to ClassLibrary2 could not e added.
Converting a type library to a .Net Assembly failed. Type library
ClassLibrary2 was exported from a CLR assembly and can not be reimported as a
CLR assembly."
Ok. I guess that means I don't do that. So, I'll add a reference to the
project. No problem. It works. I pause for a minute to wonder what I would
do if it wasn't in the same project, but move on. Except....
What I really want is to call the serviced component from a Windows Service.
So, I created a Windows Service, and did exactly what I had done for the
windows Forms app. I added a call to new ClassLibrary2.Class1() in the
OnStart method, which was exactly what I had done for the Forms App, except
that in the forms app, I put the call in the form load event handler.
This time, the service wouldn't start, and I got a File not found exception,
which I saw by looking in the Application Event Viewer.
Is there something special I have to do to call a serviced component from a
Windows Service?
Sam Santiago - 18 Oct 2004 23:36 GMT
Have you seen this example:
Serviced Component Example
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cp
conservicedcomponentexample.asp
Thanks,
Sam

Signature
_______________________________
Sam Santiago
ssantiago@n0spam-SoftiTechture.com
http://www.SoftiTechture.com
_______________________________
> I'm having trouble creating and consuming a serviced component.
>
[quoted text clipped - 29 lines]
> Is there something special I have to do to call a serviced component from a
> Windows Service?
David - 19 Oct 2004 13:59 GMT
Thanks. Yes. I patterned what I did off of that example, and it worked fine
when the client application was a Windows forms app. But as a service, it
didn't work.
> Have you seen this example:
>
[quoted text clipped - 49 lines]
> a
> > Windows Service?
[MSFT] - 19 Oct 2004 03:30 GMT
Hi David,
For a Windows Service application, you need to set it run under local
System account or a local administrator account, so that it has enough
permission to invoke your Serviced component.
Hope this help,
Luke
David - 19 Oct 2004 13:57 GMT
Thanks, but I'm still stuck. It says it can't find my file, or one of its
dependencies. But from the forms app in the same solution, everything works
fine.
> Hi David,
>
[quoted text clipped - 5 lines]
>
> Luke
David - 19 Oct 2004 20:59 GMT
It seems that when I recompiled the serviced component, I didn't reregister
it in the GAC.
> I'm having trouble creating and consuming a serviced component.
>
[quoted text clipped - 29 lines]
> Is there something special I have to do to call a serviced component from a
> Windows Service?
[MSFT] - 20 Oct 2004 04:00 GMT
Thank you for the clarify, If you have any question during the development,
please feel free to post in the community.
regards,
Luke