【问题标题】:How to implement IObjectSafety programmatically in JScript.NET如何在 JScript.NET 中以编程方式实现 IObjectSafety
【发布时间】:2011-12-23 22:37:57
【问题描述】:

tldr;如何将 JScript.NET dll 标记为安全的脚本?

考虑一下这个 JScript.NET 库(helloworld1.js)

package helloworld1{
  class test1 {
    public function test1run(){
      return 'This is a string returned from helloworld1.dll';
    }
  }
}

运行后

jsc.exe /nologo /t:library helloworld1.js

regasm /nologo /codebase helloworld1.dll

我可以在我的本地 html 页面上使用它:

var helloworld1 = new ActiveXObject("helloworld1.test1");
alert(helloworld1.test1run());

一切正常,我收到This is a string returned from helloworld1.dll 的提醒。

现在...我想摆脱每次实例化 ActiveX 对象时弹出的可怕 IE 安全警告

An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?

我知道删除安全警告的方法是将dll标记为safe for scripting并实现IObjectSafety

我知道如何在 VB6 和 VB.NET 中执行此操作,但如何在 JScript.NET 中实现它?

非常感谢任何帮助。

【问题讨论】:

  • @Erik Philips:我不这么认为。据我所知,这个问题是关于使用真实证书签署 dll,我的问题涉及在 JScript.NET 中实现 IObjectSafety
  • 你说I want to get rid of the dreaded IE security warning which pops up every time the ActiveX object is instantiated,这需要对你的DLL进行签名,这也需要实现IObjectSafety
  • @Erik Philips:我在问题标题中添加了programmatically。希望能让你满意。

标签: .net jscript jscript.net


【解决方案1】:

经过大量研究后我发现,由于 JScript.NET 中绝对没有 IObjectSafety 的文档,因此我无法直接在代码中实现此接口。

我终于安定下来,添加了将我的 dll 标记为“初始化安全”和“脚本安全”所需的注册表项:

[HKEY_CLASSES_ROOT\CLSID\[MY_COM_CLASS_GUID]\Implemented Categories\{7DD95801-9882-11CF-9FA9-00AA006C42C4}]
[HKEY_CLASSES_ROOT\CLSID\[MY_COM_CLASS_GUID]\Implemented Categories\{7DD95802-9882-11CF-9FA9-00AA006C42C4}]

当 helloworld1.dll 部署在目标机器上时,我会在设置例程中添加这些键。它完美无瑕。

【讨论】:

  • 但是……但是……它实际上对脚本不安全?叹息。
  • @x0n:不,这不安全。事实上,这是非常危险的。不要尝试。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-18
  • 2012-02-09
  • 2012-02-13
  • 2020-08-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多