2010-12-06 111 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