Skip to content

Call kernel.Get<T> two times do not give the same result #262

@Xebast

Description

@Xebast

Ninject Version : Current Release (Version 3.2)

In sample application below, we want to verify that multiple call to Get give the same result : throw Activation Exception - because we did not bind any IWeapon object - .

image

The first call is OK, exception is raised (visualized in Text Visualizer) :

image

Unfortunnately, the second call does not throw exception and return an instance of Samurai.
This is not what we expect.
We check that Context class uses Cache for Resolution :

  • that stores an instance, created during the first call of Get (cache.Remember(this, reference)
    (Cache is not cleared, even if ActivationException occurs after)
  • that returns this instance during second call :

image

This behavior is strange (same method Get called twice gives different result), but maybe we are wrong in our expected result ? Or Maybe we have to modify Ninject Setting ? (We turned ActivationCacheDisabled to True, but no impact)
image

Note : same behavior in pending V4 version.

Someone could help ?
Thanks.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions