Multiple implementations of an interface

Hi,

Here is my situation.

1.) I have an internal interface with an [ExternalDataExchange] attribute

2.) I have two classes which implement my interface

3.) I have a workflow with a CallExternalMethodActivity where I hook in the interface type and method name

4.) 1,2 and 3 are all in the same namespace

My problem is that when I run the app the workflow seems to hook into the methods of the first class which implements the interface but does not notice the second. How does WWF deal with this case What is the correct way to implement something like this

Thanks,

Nathan




Answer this question

Multiple implementations of an interface

  • vsto-newbie

    Hi Nathan,

    I am confused here. Are you adding the two services (implementations of the same interface) to the ExternalDataExchangeService The host throws an exception if you add the same interface implementations through two different services to the external data exchange service.



  • Jonathan Brown

    Thanks Matt. That makes a lot of sense. Saurabh thanks for your answer. I updated to the newest versions and just for customer feedback it is incredibly painful and time consuming to update, it's unclear what needs to be updated and where. Anyway it does compile! My .NET version is now 3.0.04324.17. Anyway consider this the end of my problem. Thanks guys.

  • progames25

    Hi Nathan,

    It seems that you are using an old build and you might want to upgrade to the latest build which is RC5. You can find the steps to upgrade in this post.

    I still have doubts about this scenario because there is no way to specify the interface implementation within a call external method activity, you only specify the interface type. I think you can chose the different paths within the same implementation of the interface by passing the parameters like the manager level. In any case with RC5 I get a runtime exception when I try to add second service with the same interface type to the ExternalDataExchange service.

    If you still face the same issue with the new build please send me a small repro by email at schechi@microsoft.com. I would be glad to investigate further.

    Thanks,



  • RueSam

    Hi Saurabh,

    "Are you adding the two services (implementations of the same interface) to the ExternalDataExchangeService " yes

    Let me clarify what I'm really asking. Windows Workflow Foundation workflow communication services implement a mechanism for objects to communicate with a workflow instance via a communications channel. The definition of the communications channel is an interface and its implementation is a service class that is added to the runtime to facilitate communication. Is it possible to have multiple classes which implement the interface Why or why not

    For example lets say I have an IExpenseService interface with Approve, Reject Reports and RequestManagerApproval functions which some manager may wish to use to do his work. Isn't it possible that I may want to have different implementations of this for different types of managers

    Thanks,

    Nathan

    ps I have multiple classes implemented for the interface. The code compiles but picks the first class to run. I have .NET version 3.0.04131.06

     



  • Rush hour

    Nathan,

    You can have separate implementations of the interface, but you can only add a single instance to the runtime at once. For example, you might have one implementation when the workflows are hosted in winforms, and one when they are hosted in ASP.NET. that is the beauty of using interfaces from the workflow because it doesn't care what the implementation is.

    Matt



  • Multiple implementations of an interface