.NET Applet 和 IE 中嵌入的 ActiveX 控件有什么区别

发布于 2024-07-19 03:59:59 字数 371 浏览 3 评论 0原文

我在网上看到了一些关于 .Net 小程序的文章,我想知道它与 activex 控件(使用 .Net 语言创建)有何不同? (澄清一下,这是关于在网络浏览器内运行的小程序)

(区别是:用 .Net 语言编写的 ActiveX 控件称为 .Net 小程序吗?)

使用其中一种比另一种有什么优势吗?

另外,微软将该技术称为什么? (在 MSDN 上搜索并没有找到任何称为 .Net Applet 的内容!)

ps:据我所知,ActiveX 控件需要进行 COM 注册,而 .Net applet 则不需要。 此外,在网页中,activeX 控件是使用其 CLSID 引用的,而 .NET 小程序似乎是通过全名(路径、dll 名称、命名空间和类)引用的

I have come across some articles on the web about .Net applets and I was wondering how it differed from an activex control (created using a .Net language)? (to clarify, this is with regards to applets that run inside a web-browser)

(Is the difference: ActiveX controls written in a .Net language are called .Net Applets?)

Are there any advantages in using one over the other?

Also, what does Microsoft reference this technology as? (A search on MSDN doesnt bring anything up called .Net Applets!)

ps: from what I can see ActiveX controls need to be COM registered, whereas .Net applets dont. Also, in the web-page, activeX controls are referenced using their CLSID, whereas the .NET applets seem to be referenced by a full name (path, dll name, namespace and class)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

海拔太高太耀眼 2024-07-26 03:59:59

ActiveX 控件只是至少实现 IUnknown 的 COM 对象。 最新版本的 IE 也开始要求对象实现 IObjectSafety。 为了做任何有用的事情,该对象还需要实现一些其他 Ole 接口,例如 IDispatch、IOleObject 等。该对象需要可以通过 CoCreateInstance() 创建,这意味着您必须 通过注册表以某种方式注册。 您不必在标记中使用 guid,还可以使用 AppId(如果您注册了一个)。

您还可以编写一些托管代码并使其在 IE 中运行。 工作方式是 CLR 注册 MIME 过滤器< /a> 安装时。 然后,当 IE 发现您正在发送正确的 mime 类型时,它会将代码交给 CLR 来处理。 CLR 对代码进行沙箱处理,使其仅被授予 Internet 权限,因此它无法执行框架公开的所有操作。 您必须检查具体文档,了解在此安全区域中可以做什么和不能做什么。

一些权衡:

易于安装:ActiveX 控件要求您将所有内容打包到 .CAB 文件中,并使用 .INI 文件以相当神秘的方式描述安装要求。 如果您必须安装模块的附加依赖项(例如 ATL/MFC dll 或其他第三方模块),那么这会变得非常棘手。 使用 .net 模块,您只需使用正确的 MIME 类型将其发送下来,但您必须确保您的用户拥有正确的框架版本(您可以通过网站上的用户代理字符串进行检查)。

安全性:ActiveX控件只是在用户系统上运行的本机代码,因此理论上它们可以做任何他们想做的事情。 实际上,LoRIE 在许多情况下限制了它,您必须执行一系列特殊的操作,例如注册表和文件系统访问(请参阅 了解并在保护模式下工作)。

线程:由于 ActiveX 控件在浏览器 UI 线程上运行,因此您必须确保不在该线程上执行长时间的阻塞操作,因此您必须自己进行线程处理。 如果您的长阻塞操作操作 DOM,则必须自己编组 IHTMLxxx 接口,可以使用 GIT 或 COM 编组函数。 我不确定 .net 小程序是否在浏览器 UI 线程上运行,但我确信在 C# 中处理起来更容易。

浏览器对象:如果您想在托管扩展中使用 IE / Shell 对象,则大多数时候您必须自己编写互操作,因为框架不能很好地将这些接口包装在托管对象中。 请参阅 http://pinvoke.net 获取一些入门帮助。

兼容性:在同一进程中托管不同版本的运行时存在问题。 直到最近这还是不可能的,但我认为在 3.x 版本中它已经开始在一定程度上变得可能。 结果是,如果您以 .net 2.0 为目标,而其他人已经将 .net 1.0 作为其浏览器扩展的一部分加载,那么您就输了。 一般来说,IE 和 Windows Shell 不支持托管扩展。 此 .net 应用程序 MIME 过滤器内容可能是一个值得注意的例外,但请注意可能存在潜在问题。

ActiveX controls are simply COM objects that, at a minimum, implement IUnknown. Recent versions of IE have started to also require the object to implement IObjectSafety. To do anything useful, the object needs to implement some other Ole interfaces as well, such as IDispatch, IOleObject, etc. The object needs to be create-able via CoCreateInstance() which means you have to register it in some way with the registry. You don't have to use a guid in the tag, you can also use the AppId if you register one.

You can also write some managed code and get that running inside IE as well. The way that works is the CLR registers a MIME filter when it is installed. Then when IE sees you're sending down something of the proper mime type, it hands the code off to the CLR to handle. The CLR does sandbox the code to the extent that it is only granted Internet permissions, so it can't do everything the framework exposes. You'll have to check specific documentation for what can and can't be done in this security zone.

Some trade-offs:

Ease of Installation: ActiveX controls require you to pack everything up into a .CAB file with an .INI file that describes the installation requirements in a fairly cryptic manner. If you have to install additional dependencies with your modules (such as ATL/MFC dlls, or other third party modules) it gets pretty tricky. With the .net module, you just send it down with the right MIME type, but you have to make sure your users have the right version of the framework (which you can check via user agent string on your website).

Security: ActiveX controls are just native code running on the users system, so in theory they can do whatever they want. In practice LoRIE limits it in many cases and you have to do a bunch of special casing of things like Registry and File System access (see Understanding and Working in Protected Mode).

Threading: Since ActiveX controls run on the browsers UI thread, you have to make sure you don't do long blocking operations on that thread, so you have to do the threading yourself. If your long blocking operation manipulates the DOM, you have to Marshal the IHTMLxxx interfaces yourself, either using the GIT or COM Marshalling functions. I'm not sure if the .net applets run on the browsers UI thread or not, but it's easier to handle in C# I'm sure.

Browser Objects: If you want to use IE / Shell objects in your managed extension, you have to write the interop yourself most of the time since the Framework doesn't do a great job of wrapping those interfaces in managed objects. See http://pinvoke.net to get a little help getting started.

Compatibility: There are issues with hosting different versions of the runtime in the same process. Until recently it wasn't possible at all, but I think with the 3.x versions it has started to become possible to an extent. The upshot is if you target .net 2.0 and someone else already loaded .net 1.0 as part of their browser extension, you lose. In general IE and the Windows Shell don't support managed extensions. This .net app MIME filter stuff may be a notable exception, but be aware that there may be potential issues.

柠檬色的秋千 2024-07-26 03:59:59

“ActiveX 控件(使用 .Net 语言创建)”和“.NET applet”都是“IE 中托管的 .NET 程序集”的俚语。

事实上,.NET 程序集可以托管在各种应用程序中。 请参阅:

创建 .NET 公共语言运行时的主机

"ActiveX control (created using a .Net language)" and ".NET applet" are both slang for ".NET assembly hosted in IE".

In fact, .NET assemblies can be hosted in a variety of applications. See:

Creating a Host to the .NET Common Language Runtime

离不开的别离 2024-07-26 03:59:59

ActiveX 控件没有与 .NET 小程序相同的安全限制,这可能是优点也可能是缺点,具体取决于您想要执行的操作。 .NET 小程序通常更容易开发,ActiveX 可以使用 VB6 或 C++ 创建。

ActiveX controls don't have the same security restrictions than .NET applets, that can be an advantage or disadvantage depending on what you want to do. .NET applets are in general easier to develop, ActiveX you create with VB6 or C++.

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