Service Dependency without MVP Modal?

Topics: Web Client Software Factory, UIP Application Block discussion, User Forum
Sep 27, 2007 at 3:01 AM
Hi All,

I have a Generic Database Services which created under ModuleInitializer and the code is as follows :-

Dim database As IGenericDatabase = New GenericDatabase
moduleServices.Add(Of IGenericDatabase)(database)

However, when I type the follows under my services layer.

<ServiceDependency()> _
Public Property database() As IGenericDatabase
Return _database
End Get
Set(ByVal value As IGenericDatabase)
_database = value
End Set
End Property

and execute the follows :-

Dim command As DbCommand = database.GetStoredProcCommand("spPSCALLHEADInsert")

It said the object not created.

Is this mean the service dependency only support MVP modal provided by WCSF? Or something I missed?


Sep 28, 2007 at 6:49 PM

Where do you use your Generic Database Service?
You are adding the service in the AddModuleServices method of the ModuleInitializer class, the service will be available only for that module. Then if you try to use Service Dependency from another module you get an exception because it cannot be find in the module container.
However, if you use the AddGlobalServices method, all the modules will be able to see your service.

Service Dependency is provided by Object Builder and helps you to implement Dependency Injection of your services, so it’s not related with MVP. Although while using MVP, Dependency Injection helps you to make your code much simpler, cleaner, and easy to test.

Please let me know if this helps.

Mariano Converti
Sep 29, 2007 at 7:38 AM
Yes, I placed them to the moduleInitalizer also.

BTW, I remember I called it through the workflow callExternalMethodActivity activity.
Could I still use the service dependency?