Caliburn.Micro.Autofac icon indicating copy to clipboard operation
Caliburn.Micro.Autofac copied to clipboard

GetInstance not complete (missing ServiceType == null case)

Open tracstarr opened this issue 13 years ago • 4 comments

When trying to use Bind.Model in xaml the Caliburn.Micro.Bind.ModelChanged function will call IoC.GetInstance(null, key), which is not handled in the bootstrapper getinstance method.

tracstarr avatar Aug 26 '11 11:08 tracstarr

Autofac does not support resolving by name without a type. When I checked the Caliburn.Micro discussions on this issue, there was a change recently to other areas of the code base to eliminate this type of look up. I am going to check with Rob to see if this is behavior is intended.

When I looked at the CM code, this seems like something that be easily resolved. The type is known at the point of the GetInstance call, it is just not used.

The link to the Caliburn.Micro discussion topic is http://caliburnmicro.codeplex.com/discussions/270835.

dbuksbaum avatar Aug 30 '11 00:08 dbuksbaum

thanks. let me know if you find out anything more. I agree that it's an issue in caliburn as it (obviously) leaves restrictions on IOC when not necessary. I've had to hack in my own fix for now.

tracstarr avatar Aug 30 '11 01:08 tracstarr

What did you do as a fix?

dbuksbaum avatar Aug 30 '11 01:08 dbuksbaum

I just overrode GetInstance, and when the specific key name was passed in i had to create an if statement and then manually trying to resolve by the corresponding type. Not really a clean solution, but the only one. I'm sure i could make it more generic, but i don't have time to deal with it.

tracstarr avatar Aug 30 '11 01:08 tracstarr