如何在 JScript.NET 中以编程方式实现 IObjectSafety

发布于 2024-12-22 11:54:06 字数 1023 浏览 3 评论 0原文

太棒了;如何将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

舂唻埖巳落 2024-12-29 11:54:06

经过广泛的研究,我发现,由于 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 部署在目标计算机上时,我在安装例程期间添加这些注册表项。它工作完美。

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":

[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}]

I add these keys during my setup routine, when helloworld1.dll is deployed on target machines. It works flawlessly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文