Click here to Skip to main content
15,938,218 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
Hi all,

I have the following interface:
public delegate void NotifyOnModulesAvailabilityHandler(Lazy[] modules);

public interface IModulesLoader
{
    event NotifyOnModulesAvailabilityHandler NotifyOnModulesAvailability;

    Lazy<UserControl, IModuleMetadata>[] Modules { get; set; }

    void OnImportsSatisfied();
}


I'm tring to implement this interface like this:

public class ModulesLoader : IModulesLoader, IPartImportsSatisfiedNotification
{
    #region Events

    public event NotifyOnModulesAvailabilityHandler NotifyOnModulesAvailability;

    #endregion

    #region Public Contructor

    public ModulesLoader()
    {
        DeploymentCatalogService.Instance.Initialize();

        CompositionInitializer.SatisfyImports(this);

        this.LoadModules();
    }

    #endregion

    #region Properties

    [ImportMany(AllowRecomposition = true)]
    public Lazy<UserControl, IModuleMetadata>[] Modules
    {
        get;
        set;
    }

    #endregion

    #region IPartImportsSatisfiedNotification Members

    public void OnImportsSatisfied()
    {
        var handler = this.NotifyOnModulesAvailability;
        if (handler != null)
        {
            handler(this.Modules);
        }
    }

    #endregion

    #region Private Methods
private void LoadModules()
{
    var wc = new WebClient();
    wc.OpenReadCompleted += (s, e) =>
    {
        var streamInfo = e.Result;
        var xElement = XElement.Load(streamInfo);
        var modulesList = from m in xElement.Elements("ModuleInfo")
                          select m;
        if (modulesList.Any())
        {
            foreach (var module in modulesList)
            {
                var moduleName = module.Attribute("XapFilename").Value;
                DeploymentCatalogService.Instance.AddXap(moduleName);
            }
        }
    };
    wc.OpenReadAsync(new Uri("ModulesCatalog.xml", UriKind.Relative));
}
#endregion

}


This is my IModuleMetadata:
namespace TunisiaMeeting.MefBase.Interfaces 
{ 
public interface IModuleMetadata 
{ 
string XapFilename { get; } 
string NavigateUri { get; set; } 
string Title { get; } 
int Position { get; } 
} 
}

and UserControl is System.Windows.Controls.UserControl They Both refer to the same namespace, I have only one copy of each type

I get the following error:
Error 1 'TunisiaMeeting.Extensibility.Shell.Helpers.Deployment.ModulesLoader' does not implement interface member 'TunisiaMeeting.MefBase.Interfaces.IModulesLoader.Modules'. 'TunisiaMeeting.Extensibility.Shell.Helpers.Deployment.ModulesLoader.Modules' cannot implement 'TunisiaMeeting.MefBase.Interfaces.IModulesLoader.Modules' because it does not have the matching return type of 'System.Lazy``2<System.Windows.Controls.UserControl,TunisiaMeeting.MefBase.Interfaces.IModuleMetadata>[]'. C:\Imed\TunisiaMeeting\TunisiaMeeting.Extensibility.Shell\Helpers\Deployment\ModulesLoader.cs 18 18 TunisiaMeeting.Extensibility.Shell

m pretty sure I have the same return Type Lazy<UserControl, IModuleMetadata>[] in both my class and my interface for my property.
Any Help please ?
Thank you all

[edit]Code blocks added to make reading the code easier... - OriginalGriff[/edit]
Posted
Updated 6-Dec-10 3:14am
v2

1 solution

You're "pretty sure", but I would check up: in your implementation class, totally disregard "using" clause and write all fully qualified names -- should show the source of the problem.
 
Share this answer
 
Comments
Espen Harlinn 26-Feb-11 11:14am    
Good advice :)
Sergey Alexandrovich Kryukov 26-Feb-11 19:13pm    
Thank you, OP seemingly abandoned to topic...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900