Coder Social home page Coder Social logo

Comments (16)

Alex2357 avatar Alex2357 commented on August 17, 2024

Added check "&& !behaviors.Contains(behavior)" into WcfUtils and it works

    internal static void AddBehaviors<T>(IKernel kernel, WcfExtensionScope scope,
                                       ICollection<T> behaviors, IWcfBurden burden,
                                       Predicate<T> predicate)
    {
        foreach (var handler in FindExtensions<T>(kernel, scope))
        {
            var behavior = (T)handler.Resolve(CreationContext.CreateEmpty());
            if (predicate == null || predicate(behavior))
            {
                if (behaviors != null && !behaviors.Contains(behavior)) behaviors.Add(behavior);
                if (burden != null) burden.Add(behavior);
            }
        }
    }

from windsor.

kkozmic avatar kkozmic commented on August 17, 2024

nice.

Do you want to pull request that change? Just make sure you have the tests to validate it's working

from windsor.

Alex2357 avatar Alex2357 commented on August 17, 2024

With the test it will be problem. It seems to me that something wrong as I have 133 tests failing before I did the change. I'm a bit behind of master. I'm on fd20561. I'll try to update

from windsor.

kkozmic avatar kkozmic commented on August 17, 2024

you might need to make sure you’re running as admin or that port sharing is enabled…

We should probably change the tests to give people nicer error message in that scenario… might be another pull request ;)

Krzysztof Kozmic

On Thursday, 13 February 2014 at 1:58 pm, Alex2357 wrote:

With the test it will be problem. It seems to me that something wrong as I have 133 tests failing before I did the change. I'm a bit behind of master. I'm on fd20561 (fd20561). I'll try to update


Reply to this email directly or view it on GitHub (#44 (comment)).

from windsor.

Alex2357 avatar Alex2357 commented on August 17, 2024

you might need to make sure you’re running as admin or that port sharing is enabled

Is it "or" or "and", i.e. I should run as admin AND port sharing enabled, because when I run only under admin I have 16 failed tests.

The other thing is that I'm not entirely sure if the fix I did is right. It seems to me that it is fixing a symptom.
If in some cases it comes into AddBehaviors method twice with the same parameters and on a second call I got an exception it is possible that this line

if (burden != null) burden.Add(behavior);

also should not be performed.

from windsor.

kkozmic avatar kkozmic commented on August 17, 2024

you might be right. It's been a while since I looked into this code I'm not sure what the best way to fully fix this is. That's why it's good to have tests to make sure all is good and to validate all assumptions of potential issues like this one.

I'm not sure if you need both port sharing and admin. I thought one should be enough. Have a look why the other 16 tests are failing. Perhaps there's some configuration that needs to happen.

I do agree that the experience getting up and running is less than ideal. sorry about that.

from windsor.

Alex2357 avatar Alex2357 commented on August 17, 2024

Couldn't replicate issue. But eventually I did.
My problem partly was because of my laziness. I started using this for registration

                Classes.FromAssemblyContaining<SomeType>().Pick()
                    .WithService.DefaultInterfaces().LifestyleTransient()

As result it added component with a service ArchiveSerializerContractBehaviorAttribute, IContractBehavior because in that assembly I have that class

public class ArchiveSerializerContractBehaviorAttribute : Attribute, IContractBehavior

in ServiceHostExtensions.cs

        void IWcfExtensionVisitor.VisitEndpointExtension(IWcfEndpointExtension extension)
        {
            var contracts = new HashSet<ContractDescription>();

#if !DOTNET35
            var endpoints = serviceHost.Description.NonSystemEndpoints();
#else
            var endpoints = serviceHost.Description.Endpoints;
#endif

            foreach (var endpoint in endpoints)
            {
                extension.Install(endpoint, contracts.Add(endpoint.Contract), kernel, burden);
            }
        }

at the line extension.Install(endpoint, contracts.Add(endpoint.Contract), kernel, burden);
endpoint already has a required behaviour and in Install method it will add and fail at that. The first solution was just to remove registration and I did this way

                Classes.FromAssemblyContaining<ISystemLoad>()
                    .Where(t => !"ArchiveSerializerContractBehaviorAttribute".Split(' ').Any(s => t.Name.Contains(s)))
                    .WithService.DefaultInterfaces().LifestyleTransient()

At that moment I started realizing that if I would not have interface marked with that attribute it would add succesfully the registered contract behavior and as result I would have
behavior which I didn't ask.

in WcfUtil.cs in that method

        internal static void AddBehaviors<T>(IKernel kernel, WcfExtensionScope scope,
                                           ICollection<T> behaviors, IWcfBurden burden,
                                           Predicate<T> predicate)
        {
            foreach (var handler in FindExtensions<T>(kernel, scope))
            {
                var behavior = (T)handler.Resolve(CreationContext.CreateEmpty());
                if (predicate == null || predicate(behavior))
                {
                    if (behaviors != null) behaviors.Add(behavior);
                    if (burden != null) burden.Add(behavior);
                }
            }
        }

FindExtensions<T>(kernel, scope) finds all components which are registered in the container and adds them to the endpoint.
Is that how it is supposed to work or is it a bug? I don't think that I need extensions which I didn't ask explicitly.

from windsor.

Alex2357 avatar Alex2357 commented on August 17, 2024

2 kkozmic
Can you have a look into the last post.

from windsor.

Alex2357 avatar Alex2357 commented on August 17, 2024

sorry accidentally closed

from windsor.

kkozmic avatar kkozmic commented on August 17, 2024

:)

from windsor.

Alex2357 avatar Alex2357 commented on August 17, 2024

Is that how it is supposed to work or is it a bug? I don't think that I need extensions which I didn't ask explicitly.

from windsor.

kkozmic avatar kkozmic commented on August 17, 2024

extensions? What extensions?

from windsor.

Alex2357 avatar Alex2357 commented on August 17, 2024

Please read my post (5days ago). The problem is that if in the container a class which implements IContractBehaviour was registered this behaviour will be added to a service even if I didn't mark contract with that attribute.

from windsor.

kkozmic avatar kkozmic commented on August 17, 2024

Hmm, @cneuwirt what's your opinion on this, specifically #44 (comment) ?

from windsor.

 avatar commented on August 17, 2024

@Alex2357 - this issue has not moved for 3 years, OK to close? Ideally we would like to see a pull request raised. Do you feel this is possible?

from windsor.

 avatar commented on August 17, 2024

Abandoned issue, closing.

from windsor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.