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 中实现它?
非常感谢任何帮助。
最佳答案
经过广泛的研究,我发现,由于 JScript.NET 中绝对没有 IObjectSafety 的文档,我无法直接在代码中实现这个接口(interface)。
我终于安定下来,添加了将我的 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 部署在目标机器上时,我会在设置例程中添加这些键。它完美无缺。
关于.net - 如何在 JScript.NET 中以编程方式实现 IObjectSafety,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8621232/