Issue trying to integrate HelloScreens into WPF project

Jan 24, 2011 at 8:25 PM

I have an existing WPF project that I am trying to add the DialogManager code from the HelloScreens sample project into. I have added the necessary interfaces/classes, but get the following error in the GetInstance function when MEF is composing things:

GetExportedValue cannot be called before prerequisite import Sample.ViewModels.ShellViewModel..ctor (Parameter="dialogs", ContractName="Sample.Core.Contracts.IDialogManager")' has been set.

The issue lies in my ShellViewModel. I am importing another viewmodel via the following code:

 [ImporttypeofIRibbonBar ), AllowDefault = true )]
        public IRibbonBar RibbonBar
        {
            get
            {
                return _RibbonBar;
            }
            set
            {
                _RibbonBar = value;
                NotifyOfPropertyChange( () => RibbonBar );
            }
        }

If I comment this out, everything works fine. The only thing I found regarding this error was on this page:

http://blogs.microsoft.co.il/blogs/zuker/archive/2011/01/02/mef-thread-safety-and-getexportedvalue.aspx

However, implementing his suggested fix has no effect. Any thoughts?

Coordinator
Jan 24, 2011 at 10:56 PM

You should probably ask this question in the MEF forums. If I had to guess though, the implementation of IRibbonBar probably has some sort of circular dependency.