error CS0738 Interface implementation
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
}
I get the following error:
Error 1 'TunisiaMeeting.Extensibility.Shell.Helpers.Deployment.ModulesLoader' does not implement interface member 'TunisiaMeeting.MefBase.Interfaces.IModulesLoader.Mod开发者_如何学Pythonules'. '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
I'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
You haven't shown where UserControl
and IModuleMetadata
come from... my guess is that your interface is referring to one pair of types whereas your implementation is referring to a different pair:
- Make sure they're referring to the same types in the same namespaces
- Make sure you only have one copy of each type (e.g. that you haven't got one copy in a class library, and redeclared it somewhere else)
精彩评论