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 7969809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:17:44+00:00 2026-06-04T07:17:44+00:00

I’ve just upgraded a solution from .NET 3.5 to .NET 4 In the same

  • 0

I’ve just upgraded a solution from .NET 3.5 to .NET 4
In the same time, I’ve upgraded all external libraries to the latest version, so Castle is now upgraded from 2.5.2 to v3.0

I’ve some code that register db access that throw now an Exception when I try to resolve:

[Castle.MicroKernel.ComponentResolutionException] {“Could not obtain
scope for component DF.MailFlowAdapter. This is most likely either a
bug in custom IScopeAccessor or you’re trying to access scoped
component outside of the scope (like a per-web-request component
outside of web request
etc)”} Castle.MicroKernel.ComponentResolutionException

The component is registered this way:

Container
    .AddFacility<WcfFacility>()
    .AddFacility<DataAccessAdapterFacility>()
    .Register(Component
        .For<SD.LLBLGen.Pro.ORMSupportClasses.IDataAccessAdapter>()
        .ImplementedBy<MailFlowAdapter>()
        .LifeStyle.PerWcfOperation())

The problem comes from the PerWcfOperation LifeStyle, but I don’t know why: The project is a WCF project and the component is resolved when calling a WCF method.
This registration is working fine in the branch that use Castle 2.5.

The exception is thrown when Validating the wcf login/pwd (in a IAuthorizationPolicy that use a UserNamePasswordValidator), because I resolve an IDataAccessAdapter (to check login/pwd in the db).

Other piece of information:

The DataAccessAdapterFacility is an old code that register a component activator, I had to slightly change de code because model.Service changed to model.Services:

void Kernel_ComponentModelCreated(ComponentModel model)
{
    foreach (var service in model.Services)
    {
        if (service == typeof(SD.LLBLGen.Pro.ORMSupportClasses.IDataAccessAdapter))
        {
            model.CustomComponentActivator = typeof(DataAccessAdapterActivator);
        }
    }
}

And the DataAccessAdapterActivator has in charge to create the object using a connection string in the config file:

protected override object InternalCreate(CreationContext context)
{
    var connectionString = string.Empty;
    if (ConfigurationManager.ConnectionStrings["Main"] != null)
        connectionString = ConfigurationManager.ConnectionStrings["Main"].ConnectionString;
    return new MailFlowAdapter(connectionString);
}

I think the code with DataAccessAdapterFacility/DataAccessAdapterActivator could be simplify using Factory but it’s not the question here 🙂

So does someone have an idea on why I can’t use PerWcfOperation lifestyle ?

  • 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-04T07:17:45+00:00Added an answer on June 4, 2026 at 7:17 am

    Ok Let’s resume my discussion with Craig Neuwirt on the castle mailing list:

    • The behaviour has changed, in v2.5 is was falling back on a
      transient lifestyle. But as it was not consistent (No info on when
      the component was PerWcfOperation and when it was Transient) this has
      been removed.
    • It’s possible to do the same using a custom lifestyle scope accessor

    I’ll not post my code here as it’s trivial once you’ve read how the Hybrid lifestyle are done in the castlecontrib project

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.