Base solution for your next web application
Open Closed

Dependency Registration Issue #9730


User avatar
0
MellowoodMedical created

Prerequisites

What is your product version? -> 8.1 What is your product type (Angular or MVC)? -> Angular What is product framework type (.net framework or .net core)? -> .net core

Hello,

I need to use the same class (IIdeasMessageRepository) in two different modules.

The above image shows where IIdeasMessageRepository is originally registered for dependency injection.

But, I also need to use IIdeasMessageRepository in this project.

When I don't register the dependency in this module I get this exception.

Once I register the depedency.

I get this exception instead and sometimes I get the duplicate registration error.

How can I use/register the same class in two different modules without getting an exception?


5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    hi

    I think you should depend on the IdeasMessageingModule instead of registering its service(IIdeasMessageRepository).

    Can you share the structure of your project and modules?

  • User Avatar
    0
    MellowoodMedical created

    Hello,

    I have tried using the DependsOn Attribute but when I do so, it throws this exception

    This is how the module looks like now

    As for the structure it looks like this.

  • User Avatar
    0
    maliming created
    Support Team

    hi @MellowoodMedical

    Could you share a simple project that reproduce the problem with me? [email protected]

  • User Avatar
    0
    MellowoodMedical created

    Unfortunately I do not have a sample project that can reproduce the issue.

    I will attempt to recreate it and it may take some time.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @MellowoodMedical

    Thanks, we are waiting for your reproduction project.