Closed sid5 closed 2 years ago
@sid5 Sorry for the delay answering this. First off, can you just cast it like so:
For<IMyInterface>()
.Use((IMyInterface)getImplementation())
.Singleton();
or even:
For<IMyInterface>()
.Use(s => (IMyInterface)getImplementation())
.Singleton();
No recent activity, and this wasn't a bug to begin with.
I'm in the process of attempting to migrate our solution from StructureMap to Lamar, and I'm encountering the following error any time I attempt to register a particular dependency as a singleton.
'System.Object' cannot be used for constructor parameter of type 'IMyInterface'
(This error occurs when calling
Container.AssertConfigurationIsValid()
.)Unfortunately, I can't share much of the code, but this is the relevant bit:
Curiously, if I register this as anything other than a singleton, it appears to work as expected.
While investigating this, I found issue #159 , which appears to be the same issue I'm encountering, although that was marked as closed and fixed as of v 3.0.4. (I'm using v 5.0.3.) I've tried the workaround mentioned in that issue to no avail.
Is there something that I'm doing wrong here? If not, is there a workaround that would allow me to register an instance as a singleton?