如何在 JScript.NET 中以编程方式实现 IObjectSafety
太棒了;如何将 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 / 运行它之后代码库 helloworld1.dll
我可以在本地 html 页面上使用它:
var helloworld1 = new ActiveXObject("helloworld1.test1");
alert(helloworld1.test1run());
一切正常,我收到一条警告 This is a string returned from helloworld1.dll
。
现在...我想摆脱每次实例化 ActiveX 对象时都会弹出的可怕的 IE 安全警告:
此页面上的 ActiveX 控件与其他部分交互可能不安全页面的。您想允许这种交互吗?
我知道消除安全警告的方法是将 dll 标记为脚本安全
并实现IObjectSafety
。
我知道如何在 VB6 和 VB.NET 中执行此操作,但如何在 JScript.NET 中实现它?
非常感谢任何帮助。
tldr; How to mark a JScript.NET dll as safe for scripting?
Consider this JScript.NET library (helloworld1.js)
:
package helloworld1{
class test1 {
public function test1run(){
return 'This is a string returned from helloworld1.dll';
}
}
}
After running it through
jsc.exe /nologo /t:library helloworld1.js
and
regasm /nologo /codebase helloworld1.dll
I can use it on my local html page with:
var helloworld1 = new ActiveXObject("helloworld1.test1");
alert(helloworld1.test1run());
It all works fine and I get an alert with This is a string returned from helloworld1.dll
.
Now... I want to get rid of the dreaded IE security warning which pops up every time the ActiveX object is instantiated:
An ActiveX control on this page might be unsafe to interact with other parts of the page. Do you want to allow this interaction?
I know the way to remove the security warning is to mark the dll as safe for scripting
and implement IObjectSafety
.
I know how to do this in VB6 and VB.NET but how do I go implementing it in JScript.NET?
Any help is really appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过广泛的研究,我发现,由于 JScript.NET 中绝对没有 IObjectSafety 的文档,因此我无法直接在代码中实现该接口。
我最终决定添加所需的注册表项,以将我的 dll 标记为“初始化安全”和“脚本编写安全”:
当 helloworld1.dll 部署在目标计算机上时,我在安装例程期间添加这些注册表项。它工作完美。
After an extensive research I figured out, as there is absolutely no documentation for IObjectSafety in JScript.NET, I can't implement this interface directly in the code.
I finally settled down with adding the needed registry keys for marking my dll as "Safe for initialization" and "Safe for scripting":
I add these keys during my setup routine, when helloworld1.dll is deployed on target machines. It works flawlessly.