好吧,我知道這意味着什麼,但我不知道如何解決這個問題 這裏是我的接口
錯誤無法創建抽象接口的實例 - C#
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);
}
這裏是I類使用繼承接口
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);
是什麼毛病,因爲它編譯正確的,但是當我嘗試下載一個文件,它不觸發任何東西,它不顯示在MessageBox作爲其應該做的
爲什麼你的問題標題指的是某些不在你的問題身上的東西? –