Resolve Problems

Oct 9, 2008 at 9:35 PM
Hi All,

I'm having a resolve problem that I'm struggling with at the moment, any pointers would be great.

At the initialisation of ModuleA I register a Type like:

 _container.RegisterType<IExportViewDataModel, ExportViewDataModel>(new ContainerControlledLifetimeManager());

I was under the impression this was almost like registering a Singleton?

In the same Module I need an instance of ExportViewDataModel which I get from the the container by:

this._dataModel = _container.Resolve<ExportViewDataModel>();

Now in ModuleB I also need a reference to the same instance of ExportViewDataModel which I get from the container by:

this._exportViewDataModel = _container.Resolve<IExportViewDataModel>();

However, I'm seeing the ExportViewDataModel constructor being called twice which means anything accessing the IExportViewDataModel is pushing data into one instance and the ExportViewController is pushing data into another instance of the ExportViewDataModel.  I'm really confused by this as I was under the impression that since the type is registered with the container using the LifetimeManager that I would always be provided with a reference to the same instance.

Any help, ideas would be great.

Thanks,

James.
Oct 9, 2008 at 9:45 PM
Ahh ... schoolboy error ...

I was registering my ExportPage at module initialisation BEFORE registering the type detailed above hence ... two instances kicking around ... DOH! (>_<)!!