WorkItemExtension bug when used while loading

Topics: CAB & Smart Client Software Factory
Apr 14, 2006 at 2:35 PM
originally posted by: AndrePiwoni

Declarative syntax for WorkItemExtension, ie. WorkItemExtension(typeof(MyWorkItem)), does not work when main WorkItem is created and run during loading modules.

After CabApplication.LoadModule() and ModuleLoaderService.Load is called, ModuleMetadata.InitializeModuleClasses(workItem) is called and calls Load() on all modules. When WorkItem is created and run during this time, all its DECLARED work item extensions do not work. It seems that ModuleMetadata.InitializeWorkItemExtensions(workItem) which registers these extensions is called right after.


Ensure module with extension is loaded first and extension is registered in module's load method programatically as follows:

WorkItemExtensionService.RegisterExtension(typeof(MyWorkItem), typeof(MyWorkItemExtension));

It is rather clumsy for WorkItem to declare dependency on its WorkItemExtensions but it works for now.
Better way is not to do much during loading time.
May 11, 2006 at 9:14 AM
originally posted by: aaguiarz

Did someone figured out how to fix this in the CAB code?
Jun 29, 2006 at 9:13 AM
originally posted by: aras03k

Well I wrestled with the same problem and as you mention the bug is in the CAB ModuleLoaderService. A workaround would be to use the ModuleLoaderService provided by the SC-SF since they fixed the bug there.

I just re-implemented the original ModuleLoaderService since I needed to add some authorization stuff anyway.

Too bad the service isnt fit for inheritance since the fix is very minor..

Best regads,
Aug 29, 2006 at 9:04 AM
originally posted by: mamu300B


what do you mean by "A workaround would be to use the ModuleLoaderService provided by the SC-SF since they fixed the bug there."?

As far as I know SCSF does not have its own CAB implementation. It only re-uses the binaries that come from compiling CAB.

Aug 29, 2006 at 9:04 AM
originally posted by: mshe

Public Class MyExtentionInit
Inherits ModuleInit

Private WorkItemExtensionService As New WorkItemExtensionService

Public Overrides Sub Load()
WorkItemExtensionService.RegisterExtension(GetType(CustomerWorkItem), GetType(MyWorkItemExtension))
End Sub

End Class

Does this look right? But my extensions are still not loading :(

I also tred:

Public Class AgentScriptingExtentionInit
Inherits ModuleInit

Private m_WorkItemExtensionService As WorkItemExtensionService

<ServiceDependency(Required:=False, Type:=GetType(WorkItemExtensionService))> _
Public WriteOnly Property WorkItemExtensionService() As WorkItemExtensionService
Set(ByVal Value As WorkItemExtensionService)
m_WorkItemExtensionService = Value
End Set
End Property

Public Overrides Sub Load()
m_WorkItemExtensionService.RegisterExtension(GetType(CustomerWorkItem), GetType(AgentScriptWorkItemExtension))
End Sub

End Class

But I can't inject an instance of the WorkItemExtensionService.

Any suggestions?
Aug 29, 2006 at 10:03 PM
originally posted by: aras03k


They swapped out the module loader service with their own implementation in the SCSF: "DependantModuleLoader".

Read more about it here:

But other than that you are correct. The SCSF operates on the original CAB binaries.
Aug 30, 2006 at 8:35 AM
originally posted by: mshe

Was it a lot of work to swap out the loader?

I dropped in the DependentModuleLoader but it seems that other classes need ot be changed as well?
Aug 30, 2006 at 9:29 PM
originally posted by: aras03k

I haven't tried the swappin part since I just took the original moduleloader class from the CAB source and added it to my project. I didnt have much need for the features the new dependant loader offered.