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

  • SEARCH
  • Home
  • 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 9157623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:04:21+00:00 2026-06-17T13:04:21+00:00

I am designing a WPF application using MVVM and I am experimenting with the

  • 0

I am designing a WPF application using MVVM and I am experimenting with the UnityContainer to resolve my MVVM objects. My problem is that my UnityContainer needs references to all my Views and ViewModels to construct the appropriate object that I need. This is fine except when one of those ViewModels needs to open a new window. To handle this I thought of having a DialogService that would get MVVM objects from the UnityContainer and then open the new window. This ends up creating a circular dependency because my ViewModel needs to see the DialogService, the DialogService needs to see the UnityContainer, and my UnityContainer needs to see my views and viewmodels. I’m not using Prism or anything just the UnityContainer installed form Nuget. The following is a pseudo-code simplified version of my problem.

Assembly-Interfaces (I reference nobody)

  • IViewX
  • IViewY
  • IViewModelX
  • IViewModelY

Assembly-Views (I reference Interfaces)

  • ViewX : IViewX
  • ViewY : IViewY

Assembly-ViewModels (I reference Interfaces and DialogService) <- this is circular dependency

  • ViewModelX : IViewModelX
  • ViewModelY : IViewModelY

Assembly-MyUnityContainer (I reference Interfaces, Views, and ViewModels)

  • UnityService (provides access to the UnityContainer)

Assembly-DialogService (I reference Interfaces and MyUnityContainer)

  • DialogService

Obviously my design is flawed. I’m just not sure what is the right way to use the UnityContainer from anywhere since it has to have references to everywhere in order to resolve my Views and ViewModels. So those of you experienced with using UnityContainer what am I doing wrong and how would you recommend I design this? Btw I am using WPF 4.5.

Note: My problem is design related, I literally cannot add a reference to my DialogService in my ViewModel, VS won’t allow it. This is not the problem where a circular dependency causes a stack overflow. Just wanted to make that clear.

Thanks!

EDIT: RESOLUTION
As per the advice I received I ended up doing a design similar to the following.

Design: How assemblies reference each other.

The MainApp sees everything, so it creates the UnityContainer, registers all of the types and hands it to the DialogService assembly as an IUnityContainer. Now the DialogService assembly can resolve any interface type without knowing about the concrete implementations. The ViewModel can use DialogService to create dialog services, which in turn open windows or other dialogues. The ViewModel just needs to know about the interface that it wants to open and give that to the DialogService, the dialog service does the work of opening the window.

  • 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-06-17T13:04:22+00:00Added an answer on June 17, 2026 at 1:04 pm

    I would say that ideally, Assembly-MyUnityContainer is the one that should reference everything.

    So in order to break the dependency from Assembly-DialogService to Assembly-MyUnityContainer, you need to stop depending on interfaces or classes in Assembly-MyUnityContainer from Assembly-DialogService.

    Why not add your own IContainer interface to your interfaces assembly, which abstracts the Unity Container? Then have the dialog service assembly only refer to the interfaces assembly…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I am designing an application using WPF, EF and MVVM (.NET4.0). I face
Using MVVM Light, I have two WPF applications that reference a common Views library.
We're designing a WPF / MVVM application that allows the user to search and
I'm using Caliburn and the MVVM pattern in a WPF application, and am trying
I am designing a WPF application that uses a DLL with maybe 40 public
I have a WPF application that mostly follows MVVM, which I am trying to
I am building an application using WPF, MVVM, and PRISM. the application is an
I am designing a very simple C# WPF application, following the MVVM pattern, with
I'm designing a WPF program that will use a DLL-plugin architecture. The host application
While designing a new WPF application I noticed exceptions not being thrown during data

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.