5

因此,我一直在努力更新旧扩展以供 FF4 和 Gecko 2 使用,但我遇到了一些问题,我收到一个错误,提示组件的 classID 丢失或不正确......

有没有其他人遇到过类似的问题或知道如何解决这个问题?

function jsshellClient() {
  this.classDescription = "sdConnector JavaScript Shell Service";
  this.classID = Components.ID("{54f7f162-35d9-524d-9021-965a3ba86366}");
  this.contractID = "@activestate.com/SDService?type=jsshell;1"
  this._xpcom_categories = [{category: "sd-service", entry: "jsshell"}];
  this.name = "jsshell";
  this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
      .getService(Components.interfaces.nsIPrefService)
      .getBranch("sdconnector.jsshell.");
  this.enabled = this.prefs.getBoolPref("enabled");
  this.port = this.prefs.getIntPref("port");
  this.loopbackOnly = this.prefs.getBoolPref("loopbackOnly");
  this.backlog = this.prefs.getIntPref("backlog");
}
jsshellClient.prototype = new session();
jsshellClient.prototype.constructor = jsshellClient;

当为此在原型上调用 generateNSGetFactory 时,它会在 FF4 的错误控制台中给出一个错误,抱怨 classID。我很确定没有其他东西在使用相同的 GUID,所以我看不到问题所在。

4

2 回答 2

2

Fx4 中 JS XPCOM 组件的一个重要变化是它们现在需要在 chrome.manifest 中注册,有关更改的文档请参阅此页面。

于 2010-10-23T21:09:08.027 回答
0

XPCOMUtils 使用的特殊属性,如 classID、contractID 等,必须在 Class.prototype 上定义,而不是在构造函数中定义,就像您所做的那样:https ://developer.mozilla.org/en/XPCOMUtils.jsm #Class_declaration

至于您在评论中发布的另一个问题,请在另一个问题中发布,如果它仍然相关,并提供必要的代码。

于 2011-01-09T19:50:17.643 回答