Wrong Service-LoadOrder causes ServiceMissingEx

Topics: CAB & Smart Client Software Factory
Jul 5, 2006 at 11:42 PM
originally posted by: KayLerch

Hello,

the services don't want to be my friends.
The ModuleServiceLoader identifies all of my services correctly. On of these services has a service dependency to service2. Unfortunetly service2 is load after this one. So CAB throws an ServiceMissingException.
Since I made some changes in the service's, the problem occurs. before that, everything was fine.

How does CAB set its load order for the services? Can I manipulate the order?
I thought that CAB identfies all depenedies and then set its order. so why not in my case?

thank you for any ideas
Kay
Jul 8, 2006 at 10:34 PM
originally posted by: askew

Chris Holmes wrote this reply in another thread today. It bears directly on your question.


"CAB and the Offline Application Block Posted on: 07/07/2006 08:42:19

So, if I get this right, you have the Offline stuff as a service, and the Job stuff as a service, and the Job stuff has a dependency on the Offline service.

You should be able to have one service dependent on another. The CAB Dependency Injection system should automatically wire up that dependency if you declare it.

Do you have an ServiceDependency declared for the JobServiceAgent? Should look something like this:

public class JobServiceAgent{

private ObjectBlockBuilder builder;

public JobServiceAgent(ServiceDependecy ObjectBlockBuilder builder){

this.builder = builder;
}
}


Then when you create the new JobServiceAgent, the DI framework automatically handles the injection:

JobServiceAgent jsAgent = Services.AddNew<JobServiceAgent>();

I tested this out with a couple classes that just print strings and it does work. "


The hands on lab has this on the Object Builder:

"The Object Builder is a generic dependency injection system that can be used to manage complex object dependencies and help to decouple objects in complex systems. It is a new project that was created and inspired by the requirements of the Composite UI Application Block (CAB).

As its name suggests, the Object Builder will help you to construct objects by automatically resolving and injecting dependencies where they are marked in the objects as special attributes."