错误CS0738接口实现 [英] error CS0738 Interface implementation

查看:102
本文介绍了错误CS0738接口实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有以下界面:

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

}



这是我的IModuleMetadata:



This is my IModuleMetadata:

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


和UserControl是System.Windows.Controls.UserControl它们都引用相同的名称空间,每种类型只有一个副本

我收到以下错误:
错误1"TunisiaMeeting.Extensibility.Shell.Helpers.Deployment.ModulesLoader"未实现接口成员"TunisiaMeeting.MefBase.Interfaces.IModulesLoader.Modules". ``TunisiaMeeting.Extensibility.Shell.Helpers.Deployment.ModulesLoader.Modules''无法实现``TunisiaMeeting.MefBase.Interfaces.IModulesLoader.Modules'',因为它没有匹配的返回类型为``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> [].
有任何帮助吗?
谢谢大家

添加了代码块以使阅读代码更容易...-OriginalGriff [/edit]


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]

推荐答案

您很确定",但是我会检查:在实现类中,完全忽略"using"子句,并写出所有完全限定的名称-应该显示问题的根源.
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.


这篇关于错误CS0738接口实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆