none
Deriving word template from shared custom document base class in different word template projects RRS feed

  • Question

  • Hi,

    I'm used to develop several Word 2010 template projects in VSTO at the moment. Since they share a more complex code base I decided to have a custom document base class to be inserted in derivation path. That custom document base class is located in a separate assembly every project is linked with.

    For demonstration here the class may be called MySharedAssembly.MyDocumentBase. Having a project MyTemplate with default class MyTemplate.ThisDocument I tried editing MyTemplate\ThisDocument.Designer.xml so /hostitem:hostItem@hostitem:baseType is now "MySharedAssembly.MyDocumentBase". Next I've changed MyTemplate\ThisDocument.Designer.cs to properly derive the contained partial class from MySharedAssembly.MyDocumentBase either.

    I was able to successfully compile that w/o any error or warning and could start or deploy it successfully. BUT: next time I'm opening the dotm file in designer mode the XML gets modified so attribute above is reverted to the original basetype and derivation in ThisDocument.Designer.cs is reverted as well.

    For sure, replacing all data in its XML file might be designer's expected behaviour, though it's possible not to do so. Since I've changed /hostitem:hostItem@hostitem:namespace on duplicating existing projects as well (BTW with success) and designer isn't reverting namespace equivalently I'm wondering if this issue is a bug or a feature and - in latter case - if there is a better practice to have a different base class for document template projects.

    Are there any properties or similar to (persistently) customize derivation here?


    • Edited by Soletan Tuesday, October 11, 2011 2:39 PM
    • Moved by Bogdan Petru Roiu Monday, October 24, 2011 2:23 PM english vsto forum (From:Visual Studio Tools for Office (VSTO))
    Tuesday, October 11, 2011 2:37 PM

All replies

  • Hi Soletan

    You may find you'll get a prompter answer in the English language VSTO forum:

    http://social.msdn.microsoft.com/Forums/en-US/vsto/threads


    Cindy Meister, VSTO/Word MVP
    Wednesday, October 19, 2011 1:27 PM
    Moderator
  • Hi Soletan,

     

    Thanks for posting in the MSDN Forum.

     

    Would you please tell me the MySharedAssembly.MyDoucmentBase is a class library or other type of project?

     

    Have a good day,

     

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, October 31, 2011 2:24 AM
    Moderator
  • Hey Tom,

    can't actually remember. Is there an opportunity to see the type of project somewhere. Nevertheless I think it's a library project. I see there is a AssemblyInfo.cs with ComVisible set false. Is it probably helpful to enable COM visibility here?

    Best Regards!

    Wednesday, November 16, 2011 11:34 PM