好吧我知道这意味着什么,但我不知道如何解决它
这是我的界面
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);
}
这是我用来继承接口的类
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
DownloadProgressListenerClass DLListener = new DownloadProgressListenerClass();
DLManager = Xpcom.GetService<nsIDownloadManager>("@mozilla.org/download-manager;1");
DLManager.addListner(DLListener);
它有什么问题,因为它编译正确但当我尝试下载文件时它不会触发任何内容而且它不会显示消息框应该这样做
答案 0 :(得分:0)
我怀疑你的addListener方法期望代码行中的接口类型为nsIDownloadProgressListener
:
DLManager.addListner(DLListener);
如果是这样,请将您的DownloadProgressListenerClass DLListener = new DownloadProgressListenerClass();
更改为nsIDownloadProgressListener DLListener = new DownloadProgressListenerClass();
如果您需要解释,请与我们联系。