Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:44:24+00:00 2026-05-27T01:44:24+00:00

I am quite new to C# / WPF , however this is what I

  • 0

I am quite new to C# / WPF, however this is what I used for this project.

Let me introduce the context : I have an application which allows a user to login. I have some basic information data (physical location) and some dynamic information (user name…). I dealed with all of that with a singleton manager.

This basic application is used with two different projects : after login, the application has to display xaml pages for the current running project.

Some configuration enum allows me to instanciate the right object from the right project assembly through a generic interface ( I guess I should have use WCF… we’ll see that later on 🙂 ).

Now I need some of the information, dealed by the singleton manager, in the project assembly. How can I do ?

I can’t share the singleton… Should i write a common db ? Or get rid of the singleton ? I am a bit lost. This is certainly simple architecture problem, but I can’t figure it out.

Thanks a lot for your help !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:44:25+00:00Added an answer on May 27, 2026 at 1:44 am

    I suggest you use MEF for importing and exporting information from different DLL’s. Each DLL could have resources (like XAML files) for view providing. So, my choice is MVVM + MEF modularity + Prism EventAggregator for interaction beetwen modules.
    Some samples, for concept demonstration only:

    Kind of ‘singleton manager’:

    public class AddinsManager : IAddinsManager
    {
        [ImportMany(typeof(IModule))]
        private OrderingCollection<IModule, IOrderMetadata> modules = new OrderingCollection<IModule, IOrderMetadata>(lazyRule => lazyRule.Metadata.Order);
    
        private CompositionContainer container;
        private bool isInitialized = false;
    
        /// <summary>
        /// Gets available application modules (add-ins)
        /// </summary>
        public List<IModule> Modules { get; private set; }
    
        /// <summary>
        /// Initialize manager
        /// </summary>
        public void Initialize()
        {
            Assembly oAssembly = Assembly.GetAssembly(Application.Current.GetType());
            this.container = new CompositionContainer(GetCatalog(oAssembly));
            this.container.ComposeParts(this, Context.Current);
    
            this.Modules = this.modules
                                .Select(lazy => lazy.Value)
                                .ToList();
    
            this.isInitialized = true;
        }
    
        /// <summary>
        /// Initialize modules
        /// </summary>
        public void InitializeModules()
        {
            foreach (IModule oModule in this.Modules)
            {
                oModule.Initialize();
            }
        }
    
        /// <summary>
        /// Injects dependencies in specified container
        /// </summary>
        /// <param name="host">Container to inject in</param>
        public void Compose(object host)
        {
            if (host == null)
            {
                throw new ArgumentNullException();
            }
    
            this.EnsureInitialize();
    
            this.container.ComposeParts(host);
        }
    
        /// <summary>
        /// Register views of the modules
        /// </summary>
        public void RegisterViews()
        {
            this.EnsureInitialize();
    
            foreach (IModule oModule in this.Modules)
            {
                foreach (Uri oUri in oModule.GetViewPath().ToArray())
                {
                    ResourceDictionary oDictionary = new ResourceDictionary();
                    oDictionary.Source = oUri;
                    Application.Current.Resources.MergedDictionaries.Add(oDictionary);
                }
            }
        }
    
        /// <summary>
        /// Get catalog for modules load
        /// </summary>
        /// <param name="assembly">Assembly to search modules</param>
        /// <returns>Catalog for modules load</returns>
        private static AggregateCatalog GetCatalog(Assembly assembly)
        {
            string sDirName = Path.GetDirectoryName(assembly.Location);
            DirectoryCatalog oDirCatalog = new DirectoryCatalog(sDirName, "Company.*");
            AssemblyCatalog oAssemblyCatalog = new AssemblyCatalog(assembly);
    
            AggregateCatalog oCatalog = new AggregateCatalog(oAssemblyCatalog, oDirCatalog);
            return oCatalog;
        }
    
        /// <summary>
        /// Ensure if manager was initialized
        /// </summary>
        private void EnsureInitialize()
        {
            if (!this.isInitialized)
            {
                throw new Exception("Add-ins Manager Component not initialized");
            }
        }
    }
    

    Module (DLL for separate project) implementation

    [Export(typeof(IModule))]
    public class LayoutsModule : AModule
    {
        private static LayoutsVM viewModel;
    
        /// <summary>
        /// Gets reporting add-in main view model
        /// </summary>
        public static LayoutsVM ViewModel
        {
            get
            {
                if (viewModel == null)
                {
                    viewModel = Context
                                    .Current
                                    .LayoutManager
                                    .ModulesVM
                                    .OfType<LayoutsVM>()
                                    .FirstOrDefault();
                }
    
                return viewModel;
            }
        }
    
        /// <summary>
        /// Initialize module
        /// </summary>
        public override void Initialize()
        {
            Context
                .Current
                .EventAggregator
                .GetEvent<MenuInitializing>()
                .Subscribe(this.InitializeMenu);
    
            base.Initialize();
        }
    }
    

    View as embeded resource (View.xaml) on each DLL.

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:vm="clr-namespace:Company.Client.ViewModels">
    
        <DataTemplate DataType="{x:Type vm:ApplicationVM}">
            <ContentPresenter Content="{Binding AddinsViewModel}" />
        </DataTemplate>
    
        <DataTemplate DataType="{x:Type vm:MenuVM}">        
            <ContentPresenter Content="{Binding RibbonData}" />
        </DataTemplate>
    
    </ResourceDictionary>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am quite new to WPF.I came accross this wonderful project . I have
I have problem with WPF - I'm quiet new in this smart technology. So
I am currently developing a new WPF application and have the majority of my
I have a WPF (.NET 3.5) control which renders about 20000 rectangles. This MyControl
I have a Web Service project and a WPF project (which serves as a
I have been writing a new version of my application in WPF. It looks
I’m quite new to Silverlight. I’m working for a project which mainly depends on
I'm quite new to WPF so I'm learning most of this the hard (but
Quite new to maven here so let me explain first what I am trying
Being quite new to rails and currently building a project, i'm begining to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.