首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误%1无法创建抽象接口- C#的实例

错误%1无法创建抽象接口- C#的实例
EN

Stack Overflow用户
提问于 2011-07-24 14:48:43
回答 1查看 378关注 0票数 0

好吧,我知道它是什么意思,但我不知道如何解决它这里是我的界面

代码语言:javascript
复制
        public interface nsIDownloadProgressListener
        {
            nsIDOMDocument getDocument();

            void setDocument(nsIDOMDocument doc);

            void OnDownloadStateChange(short state, nsIDownload aDownload);

            void OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, uint                                    
            aStateFlags, object aStatus, nsIDownload aDownload);

            void OnProgressChange(nsIWebProgress WbProgress, nsIRequest aReq, int         
            curSelfProgress, int maxSelfProgress, int curTotalProgress, int 
            maxTotalProgress, nsIDownload aDownload);

            void OnSecurityChange(nsIWebProgress wbProgress, nsIRequest aReq, uint 
            aState, nsIDownload aDownload);
            }

下面是我用来继承接口的类

代码语言:javascript
复制
          public class DownloadProgressListenerClass : nsIDownloadProgressListener
          {
              #region nsIDownloadProgressListener Members

              nsIDOMDocument Nothingreturned;

              public nsIDOMDocument getDocument()
              {
                  return Nothingreturned;
              }

              public void setDocument(nsIDOMDocument doc)
              {
              }

              public void OnDownloadStateChange(short state, nsIDownload aDownload)
              {
                  MessageBox.Show(aDownload.getId().ToString());
                  OnDownloadStateChange(state, aDownload);
              }

              public void OnStateChange(nsIWebProgress aWebProgress, nsIRequest aRequest, uint aStateFlags, object aStatus, nsIDownload aDownload)
              {
                  MessageBox.Show(aDownload.getId().ToString());

              }

              public void OnProgressChange(nsIWebProgress WbProgress, nsIRequest aReq, int curSelfProgress, int maxSelfProgress, int curTotalProgress, int maxTotalProgress, nsIDownload aDownload)
              {
                  MessageBox.Show(aDownload.getId().ToString());

              }

              public void OnSecurityChange(nsIWebProgress wbProgress, nsIRequest aReq, uint aState, nsIDownload aDownload)
              {
                  MessageBox.Show(aDownload.getId().ToString());

              }

              #endregion nsIDownloadProgressListener Members
          }

然后,我尝试将侦听器添加到DLManager,该侦听器应该工作并报告进度

代码语言:javascript
复制
            DownloadProgressListenerClass DLListener = new DownloadProgressListenerClass();
            DLManager = Xpcom.GetService<nsIDownloadManager>("@mozilla.org/download-manager;1");
            DLManager.addListner(DLListener);

它有什么问题吗,因为它编译正确,但是当我尝试下载一个文件时,它没有触发任何东西,也没有显示它应该显示的消息框

EN

回答 1

Stack Overflow用户

发布于 2011-07-24 15:20:11

我怀疑您的addListener方法需要的接口类型是

代码行中的nsIDownloadProgressListener

DLManager.addListner(DLListener);

如果是这样,请更改您的

DownloadProgressListenerClass DLListener = new DownloadProgressListenerClass();

转到

nsIDownloadProgressListener DLListener = new DownloadProgressListenerClass();

如果你需要解释,请告诉我。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6805370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档