none
Is there something like "global settings" for MAF applications? RRS feed

  • Question

  • I have an application where there are assemblies containing multiple add-ins. When I use Properties.Settings.Default to configure them, each add-in will have its own personal settings space (and its own user.config file). This is good for some applications, but I need that the add-ins in an assembly share settings.

    Is there a mechanism to achieve this, or do I have to roll my own here?

    Thursday, November 3, 2016 8:03 PM

Answers

  • Hi Kristin,

    I mean the Managed Application Framework. My application's functionality is compiled of several add-ins, where some add-ins share the same assembly.

    The solution-global Settings.settings looks like what I want. Although, I also want each assembly to be only instantiated once for memory and performance reasons. I did another approach: I created sort of "umbrella contract" with the necessary adapters which references the other contract, so I have something like:

    [AddInContract]
    public interface IFooBarContract: IContract {
    
        IList<IFooContract> Foos { get; }
        IList<IBarContract> Bars { get; }
        // more
    }

    Each assembly only contains one add-in of this type. So, I query the AddInStore for IFooBarHostView (the HostView part of this pipeline) and get one per assembly, from where I get the individual parts.

    So, when I define a Settings.settings for each assembly, all Foos and Bars from the same assembly share these settings (but other add-ins from another assembly don't), and this is what I want. I only have to make sure that I only query the AddInStore once at the very beginning. I do this in the early lifecycle of the main application, since it is WPF based, I wired this into the Startup event of App.xaml.cs.



    • Marked as answer by Windfisch Friday, November 4, 2016 6:47 PM
    • Edited by Windfisch Friday, November 4, 2016 6:51 PM Removed incorrect public modifiers (it's late, bear with me)
    Friday, November 4, 2016 6:47 PM

All replies

  • Hi Windfisch,

    I am not 100% sure understand what your MAF applications mean. What is the full name of MAF? Is it Managed Application Framework  application? If yes, we can use common Settings.settings file for entire solution,  In the Add Existing Item dialog, choose the common file. Instead of clicking the Add button, click the drop-down arrow on the right side of the Add button and choose Add As Link from the drop-down menu. For more detailed information, please refer to thread common Settings.settings file for entire solution.

    Best regards,

    Kristin


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 4, 2016 8:25 AM
  • Hi Kristin,

    I mean the Managed Application Framework. My application's functionality is compiled of several add-ins, where some add-ins share the same assembly.

    The solution-global Settings.settings looks like what I want. Although, I also want each assembly to be only instantiated once for memory and performance reasons. I did another approach: I created sort of "umbrella contract" with the necessary adapters which references the other contract, so I have something like:

    [AddInContract]
    public interface IFooBarContract: IContract {
    
        IList<IFooContract> Foos { get; }
        IList<IBarContract> Bars { get; }
        // more
    }

    Each assembly only contains one add-in of this type. So, I query the AddInStore for IFooBarHostView (the HostView part of this pipeline) and get one per assembly, from where I get the individual parts.

    So, when I define a Settings.settings for each assembly, all Foos and Bars from the same assembly share these settings (but other add-ins from another assembly don't), and this is what I want. I only have to make sure that I only query the AddInStore once at the very beginning. I do this in the early lifecycle of the main application, since it is WPF based, I wired this into the Startup event of App.xaml.cs.



    • Marked as answer by Windfisch Friday, November 4, 2016 6:47 PM
    • Edited by Windfisch Friday, November 4, 2016 6:51 PM Removed incorrect public modifiers (it's late, bear with me)
    Friday, November 4, 2016 6:47 PM