Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dependency Injection] Unable to create instance of PersonaBarContainer #3328

Closed
3 tasks done
daguiler opened this issue Nov 21, 2019 · 1 comment
Closed
3 tasks done

Comments

@daguiler
Copy link
Contributor

Description of bug

Evoq calls PersonaBarContainer.SetInstace(IPersonaBarContainer, bool) to override the default Persona Bar at application startup. The passed in IPersonaBarContainer argument is an instance of a class that derives from PersonaBarContainer.
Since 697a54e, PersonaBarContainer's constructor requires a INavigationManager argument (which is a breaking change for Evoq).
Creating an instance of INavigationManager during application start up is not possible, because:

  1. The app startup event is not a DI friendly context
  2. Globals.DependencyProvider is internal to core DotNetNuke assemblies only, so I can't call Globals.DependencyProvider.GetRequiredService<INavigationMananger>() from there.
    The alternative is to create and register our derived PB container instance using the recommended IDnnStartup method, but then it would be ignored by PersonaBarContainer.Instance property.

Steps to reproduce

  1. Create a project with references to core DotNetNuke assemblies
  2. Add a class that implements IAppEvents
  3. Implement ApplicationBegin() method
  4. Invoke PersonaBarContainer.SetInstance(IPersonaBarContainer, bool) from there

Current result

In order to call above method, an instance of INavigatorManager is required, which cannot be obtained from DI.

Expected result

There should be a way to derive from PersonaBarContainer and call the base constructor, or PersonaBarContainer.Instance should get the object from DI.

Affected version

  • 10.0.0 alpha build
  • 9.4.3 beta build
  • 9.4.1 latest supported release
@donker
Copy link
Contributor

donker commented Nov 22, 2019

Merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants