Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6352011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:07:14+00:00 2026-05-24T22:07:14+00:00

The rule Store in IoC container only services. Do not store any entities. I’ve

  • 0

The rule “Store in IoC container only services. Do not store any entities.” I’ve found in that blog and it have a lot of supporters.

There are also sample of the class constructor:

    MyClass(ILog log, 
            IAudit audit, 
            IPermissions permissions, 
            IApplicationSettings settings) {/*..*/}

where MyClass was announced as entity that should not be stored in the container.

So “IoC ready service” can’t depend on infrastructure .. services.

But now I completely do not understand how “IoC people” work with “real code”. Service in C# still will be developed as a class, and that class usually depends on class that encapsulate logging, rarely depends on the class that encapsulate custom exception handling (e.g. converting unhandled Exception to FaultContract) etc. …

I see some ways:
May be they just do not declare those infrastructure dependencies? Use them as functionality available form static methods?

Or may be “IoC supporters” think that “IoC ready” service should publish log/trace/authenticate/handleException events as a part of service contract (and then yes – – there are no “dependencies on infrastructure”)? But also that means that such service should be duplex (to post log events)…

May be theirs “services” are only proxies? Proxy do not have dependencies on infrastructure because of all infrastructure is remote, but I’m not happy to found that IoC container should be used to store only proxies. Am I right in my disappointment? But then what about MS Enterprise Library that is designed to sore loggers and handlers in the Unity container?

APPEND:

I understand it that way: there are services (with contracts), there are entities (business), and there are infrastructure stuff LogWriter, AuthenticationProvider;- creating/hosting service I initiate it with some infrastructure stuff (so I am publishing dependencies on infrastructure not on entities). What I still do not understand am I right in that or not?

APPEND 2:

After discussion I understand situation that way. ILog, etc – are services (even if they are infrastructure services) and therefore if the “MyClass” is the realization of the some service then rule is not violated. That means rule is good but sample is bad.

One problem left: I still do not understand the opposition of entities and services in one sentence without explanation. They are from different conceptual layers: 1) services-messages; and 2)business rules-entities.. So possibly first I should adopt new terminolgy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:07:15+00:00Added an answer on May 24, 2026 at 10:07 pm

    Short answer: entities should not depend on services! This is a huge part of the “inversion” part of dependency inversion. As stated in the post you linked to:

    I found the design of the question example is wrong in a sense that an entity (which MyClass is) should NOT have dependencies on infrastructure (or any other) services.

    MyClass, in your example, depends on three cross-cutting concerns, plus IApplicationSettings. The cross-cutting concerns should be introduced using AOP/dynamic proxy techniques, or pubsub-style events if you prefer. And MyClass should be injected with settings specific to its functionality by whatever service is in charge of creating instances of it. For example, PersonFactory could be injected with IApplicationSettings, then create Person objects, passing appSettings.SomePersonRelatedSetting into the Person constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rewrite rule that looks like this: RewriteEngine On RewriteRule ^$ store
One CSS rule I have learned is that you should use the relative em
The general rule, only objects allocated in the free store can cause memory leaks.
In my current project I have an ArrayList of PVectors that store xyz coordinates
I have a htaccess rule that is fixing some of my previous URL change
Anyone have a good rule of thumb for choosing between different implementations of Java
I have this rewrite rule RewriteEngine On RewriteBase /location/ RewriteRule ^(.+)/?$ index.php?franchise=$1 Which is
FxCop has the CollectionPropertiesShouldBeReadOnly rule that complains if your class has some kind of
A table can only store 10 records in a particular state, 10 users over
I have two tables which have the exact same structure. Both tables can store

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.