none
How do i use custom Serializable types with the System.AddIn framework (Managed Add-in Framework) RRS feed

  • Question

  • MSDN documentation states that Contracts (in the context of System.AddIn) must inherit from IContract and must use only the following types:

    • ...
    • ...
    • Serializable types defined in the contract assembly
    • Etc

    I'm wondering how to define these Serializable types in the contract and how to build the pipeline arround it. I can't find examples of this anywhere.

    I'm looking to define something like this

    [Serializable]
    public class Customer
    {
       public string Name {get;set;}
       public string Email {get;set;}
    }
    1. Does this type have to inherit from IContract as well?
    2. Does it need any other attributes
    3. How do I create the SideAdapters for it, do they just inherit from it?
    4. Etc.

    The reason i want this is because when the object passes through the AppDomain boundary, i want the whole thing to be serialized and passed over (i.e. by value, and not by ref)

    Thanks

    Monday, March 5, 2012 9:39 PM

All replies

  • Hi Markoueis,

    Welcome to the MSDN Forum.

    The MSDN documentation you mentioned is this one: http://msdn.microsoft.com/en-us/library/bb384205.aspx ?

    And your concerns is about this:

    Contracts must inherit from IContract and must use only the following types:

    • Other contracts that are derived from IContract.

    • Primitive data types: integers and Boolean types.

    • Serializable types defined in the contract assembly.

    • Serializable types defined in Mscorlib.dll, such as Int32 and DateTime.

    • Sealed, serializable reference types. For example, you can pass a String object through the isolation boundary because it is a sealed, serializable reference type.

    • Enumerations that are defined in the contract or in Mscorlib.dll.

    • AddInToken objects.

    • Arrays of any of the preceding listed types, except an array of contracts.

    Am I right?

    >>1. Does this type have to inherit from IContract as well?

    Yes, please take a look at the first sentence: Contracts must inherit from IContract, this is very clear you have to do this.

    >>2. Does it need any other attributes

    This depends on your requriements. If just such purpose, in my opinion, it is OK.

    >>3. How do I create the SideAdapters for it, do they just inherit from it?

    Please take a look at this sample: http://mef.codeplex.com/releases/view/79090  

    For further question, please feel free to follow up.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 7, 2012 5:58 AM
    Moderator