Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Internal Scope being accessed outside an assembly?

Back to Forum: Tech Off
  • User profile image
    JoshB

    I'm diving into WWF and noticed something that's at opposition to my original understanding of the scope modifier 'internal'.

    To create a custom activity in WWF you inherit from System.Workflow.ComponentModel.Activity and override the Execute method which is defined as:

    protected internal virtual ActivityExecutionStatus Execute(ActivityExecutionContext executionContext);

    This all works as expected but I noticed that the Execute method is marked internal. My understanding of the internal keyword is that all classes or members marked internal are only available to the containing assembly.

    How is it that Execute is available to my code?

    [Took a quick check at my code and reflector to double check my post and found something new]

    I don't actually have access to call the execute method in my derived class. This seems very interesting. So since the method is marked protected virtual, I'm allowed to override it ignoring the internal scope, but can't actually call it. Does this seem odd to anyone else? So how would I create a method that is overridable only to classes in my assembly, drop the protected modifier?

  • User profile image
    Pop Catalin Sever

    'Internal protected' means can be accessed from current assembly or by any other class that extends this one.... think of the mnodiffiers like having and 'or' between them 'internal or protected' access

  • User profile image
    JoshB

    Beautiful! I was going to say, but I can't get to the Execute method in my assembly but then I realized it's not public, it's protected, and indeed I can access execute from within the derived class.

    Thanks for the response.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.