2010-12-06 107 views
0

我有以下接口:错误CS0738接口实现

public delegate void NotifyOnModulesAvailabilityHandler(Lazy [] modules);

public interface IModulesLoader 
{ 
    event NotifyOnModulesAvailabilityHandler NotifyOnModulesAvailability; 

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

    void OnImportsSatisfied(); 
} 

我特林实现这个接口是这样的:

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 

} 

我得到以下错误:

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

我敢肯定,我也有同样的返回类型Lazy<UserControl, IModuleMetadata>[]在我的课程和我的财产界面中。

请帮忙吗?

谢谢大家

回答

1

您还没有表现出从哪儿来UserControlIModuleMetadata ...我的猜测是,你的界面指一对类型的,而你的实现是指一对不同:

  • 确保他们指的是在同一个命名空间中的相同类型
  • 确保只让每个类型(例如,你没有得到在类库一个副本的一个副本,并重新声明它的地方其他)
+0

感谢您的回复, – Imed 2010-12-06 11:58:26