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

  • SEARCH
  • Home
  • 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 8428559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:05:26+00:00 2026-06-10T05:05:26+00:00

I do this: https://stackoverflow.com/questions/12069002/autofac-resolve-with-and-without-named-parameter I register an interface. For the initialization a parameter is

  • 0

I do this:
https://stackoverflow.com/questions/12069002/autofac-resolve-with-and-without-named-parameter

I register an interface. For the initialization a parameter is needed.
A first call will pass this parameter.

On another place i want to resolve this instance of the interface too, but i don’t can pass this parameter.
Is it possible to check if this interface was already resolved (in the current scope. I use the ASP.NET WEB API)?
If i resolve it without the parameter, I get an exception.

I need to check if in the current HttpRequest-scope the is already resolved (so I can get it without passing the parameter, because if it is already resolved, the registered creation-delegate will not be called twice)

m_builder.Register<IMyClass((c, p) =>
    {
        //...
        return new MyClass;

    }).InstancePerHttpRequest();//.InstancePerApiRequest();
  • 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-06-10T05:05:28+00:00Added an answer on June 10, 2026 at 5:05 am

    First, create a class that can track whether the instance is resolved or not:

    public class Tracker
    {
        public bool IsResolved { get; set; }
    }
    

    (You may wish to pretty this up a bit :))

    Register it with the same scope as whatever you want to track:

    builder.RegisterType<Tracker>()
        .InstancePerHttpRequest();
    

    Then, in the OnActivated event, set the bool:

    builder.Register((c, p) => {
            return new MyClass();
        })
        .As<IMyClass>()
        .InstancePerHttpRequest()
        .OnActivated(e => {
            e.Context.Resolve<Tracker>().IsResolved = true;
        });
    

    You could also set the field during activation (in the first delegate) but using the OnActivated event makes it easier to generalise this if you want to.

    Finally, to check the field:

    if (container.Resolve<Tracker>().IsResolved) { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First look at this url: https://stackoverflow.com/questions/tagged/xoxoxo/ This directory does not exists but somehow stackoverflow
Referring to this question: https://stackoverflow.com/questions/2035449/why-is-oop-hard-for-me class Form { protected $inputs = array(); public function
I just finished looking at this question: https://stackoverflow.com/questions/753122/which-cloud-computing-platform-should-i-choose But, I am not certain what
This question is similar in spirit to : https://stackoverflow.com/questions/492178/links-between-personality-types-and-language-technology-preferences But it is based specifically
Example form, https://stackoverflow.com/questions/ask and I save this page to desktop. Then I edit the
I had asked a question very much similar to this in the thread: https://stackoverflow.com/questions/11259474/store-the-numericals-in-char-array-into-an-integer-variable-in-vc
This is the same question as this: https://stackoverflow.com/questions/2890620/jquery-running-a-function-in-a-context-and-adding-to-a-variable But that question was poorly posed.
This is related to this question: https://stackoverflow.com/questions/3179797/how-to-use-rubytorrent-or-other-gems I thought RubyGems is a package manager,
I am aware of this question: https://stackoverflow.com/questions/428691/how-to-encourage-implementation-of-tdd In my team, we write a lot
I found this question https://stackoverflow.com/questions/4612563/get-push-notification-from-twitter-on-status-updates , but there was no answer. I'm looking to

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.