Service and generics

Topics: CAB & Smart Client Software Factory
Nov 8, 2005 at 1:10 PM
originally posted by: sbia

Hello i've a generics class declare as service and i've this error

Microsoft.Practices.CompositeUI.Services.ModuleLoadException was unhandled
Message="Failed to load module from assembly Bixas.fugu.services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Error was:\r\nFailed to load module from assembly Bixas.fugu.services, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Error was:\r\nCan not create an instance of type 'Bixas.fugu.services.GenericService`1T'."
Source="Microsoft.Practices.CompositeUI"
StackTrace:
at Microsoft.Practices.CompositeUI.Services.ModuleLoaderService.ThrowModuleLoadException(String assemblyFileName, Exception innerException) in C:\Program Files\Microsoft patterns and practices\Composite UI Application Block October 2005 Community Technology Preview\Src\CS\CompositeUI\Services\ModuleLoaderService.cs:line 146
at Microsoft.Practices.CompositeUI.Services.ModuleLoaderService.AddServices(ModuleMetadata[] metadata, WorkItem workItem, IModule[] moduleInstances) in C:\Program Files\Microsoft patterns and practices\Composite UI Application Block October 2005 Community Technology Preview\Src\CS\CompositeUI\Services\ModuleLoaderService.cs:line 197
at Microsoft.Practices.CompositeUI.Services.ModuleLoaderService.Initialize(WorkItem workItem, IModuleInfo[] modules) in C:\Program Files\Microsoft patterns and practices\Composite UI Application Block October 2005 Community Technology Preview\Src\CS\CompositeUI\Services\ModuleLoaderService.cs:line 132
at Microsoft.Practices.CompositeUI.Services.ModuleLoaderService.Load(WorkItem workItem, IModuleInfo[] modules) in C:\Program Files\Microsoft patterns and practices\Composite UI Application Block October 2005 Community Technology Preview\Src\CS\CompositeUI\Services\ModuleLoaderService.cs:line 61
at Microsoft.Practices.CompositeUI.CabApplication`1.LoadModules() in C:\Program Files\Microsoft patterns and practices\Composite UI Application Block October 2005 Community Technology Preview\Src\CS\CompositeUI\CabApplication.cs:line 76
at Microsoft.Practices.CompositeUI.CabApplication`1.Run() in C:\Program Files\Microsoft patterns and practices\Composite UI Application Block October 2005 Community Technology Preview\Src\CS\CompositeUI\CabApplication.cs:line 53
at Bixas.fugu.shell.Module1.Main() in C:\Documents and Settings\Sebastien\My Documents\Visual Studio 2005\Projects\Bixas.fugu\Bixas.fugu.shell\Module1.vb:line 5
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


Code was :


<Service()> _
Public Class GenericService(Of T)
Implements core.Service.IGenericService(Of T)

End Class
Nov 8, 2005 at 2:35 PM
originally posted by: BradWilsonMSFT

You won't be able to decorate a generic class with the Service attribute, because it doesn't know type to use to instantiate the generic class.

Manually register one for a specific generic class instantiation.
Nov 10, 2005 at 12:40 PM
originally posted by: sbia

Ok thanks for this response. I change my code ;)