简体   繁体   English

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

[英]What is the difference between a .NET Applet and ActiveX control embedded in IE

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)? 我在网上看到一些有关.Net小程序的文章,我想知道它与ActiveX控件(使用.Net语言创建)有何不同? (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?) (区别是:用.Net语言编写的ActiveX控件称为.Net Applets吗?)

Are there any advantages in using one over the other? 使用一个相对于另一个有什么优势吗?

Also, what does Microsoft reference this technology as? 另外,Microsoft将此技术称为什么? (A search on MSDN doesnt bring anything up called .Net Applets!) (在MSDN上进行的搜索不会显示任何称为.Net Applets的信息!)

ps: from what I can see ActiveX controls need to be COM registered, whereas .Net applets dont. ps:据我所知,ActiveX控件需要进行COM注册,而.Net小程序则不需要。 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) 另外,在网页中,activeX控件使用其CLSID进行引用,而.NET小应用程序似乎由全名(路径,dll名称,名称空间和类)进行引用。

ActiveX controls are simply COM objects that, at a minimum, implement IUnknown. ActiveX控件仅仅是COM对象,至少可以实现IUnknown。 Recent versions of IE have started to also require the object to implement IObjectSafety. IE的最新版本也开始要求该对象实现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. 为了做任何有用的事情,该对象还需要实现其他一些Ole接口,例如IDispatch,IOleObject等。该对象需要通过CoCreateInstance()可创建,这意味着您必须以某种方式在注册表中注册它。 You don't have to use a guid in the tag, you can also use the AppId if you register one. 您不必在标记中使用Guid,如果您注册了一个,也可以使用AppId

You can also write some managed code and get that running inside IE as well. 您还可以编写一些托管代码,并使其在IE中运行。 The way that works is the CLR registers a MIME filter when it is installed. 有效的方法是CLR在安装时注册MIME过滤器 Then when IE sees you're sending down something of the proper mime type, it hands the code off to the CLR to handle. 然后,当IE看到您正在发送正确的MIME类型的东西时,它将代码交给CLR处理。 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. CLR会在仅授予Internet权限的范围内对代码进行沙箱处理,因此它无法完成框架公开的所有内容。 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. 易于安装:ActiveX控件要求您将所有内容打包成一个.CAB文件和一个.INI文件,该文件以相当隐秘的方式描述了安装要求。 If you have to install additional dependencies with your modules (such as ATL/MFC dlls, or other third party modules) it gets pretty tricky. 如果必须在模块(例如ATL / MFC dll或其他第三方模块)中安装其他依赖项,则将变得非常棘手。 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). 使用.net模块,您只需使用正确的MIME类型将其发送出去,但是您必须确保用户具有正确的框架版本(可以通过网站上的用户代理字符串进行检查)。

Security: ActiveX controls are just native code running on the users system, so in theory they can do whatever they want. 安全性:ActiveX控件只是在用户系统上运行的本机代码,因此从理论上讲,它们可以执行所需的任何操作。 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 ). 实际上,LoRIE在很多情况下都限制了它,您必须做一堆特殊的事情,例如注册表和文件系统访问(请参阅了解和在保护模式下工作 )。

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. 线程化:由于ActiveX控件在浏览器的UI线程上运行,因此您必须确保不要对该线程进行长时间的阻塞操作,因此必须自己进行线程化。 If your long blocking operation manipulates the DOM, you have to Marshal the IHTMLxxx interfaces yourself, either using the GIT or COM Marshalling functions . 如果长时间的阻止操作操纵了DOM,则您必须使用GIT或COM编组功能自行编组IHTMLxxx接口。 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. 我不确定.net applet是否在浏览器的UI线程上运行,但是我确定在C#中更容易处理。

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. 浏览器对象:如果要在托管扩展中使用IE / Shell对象,则大多数时候您必须自己编写互操作程序,因为Framework不能很好地将这些接口包装在托管对象中。 See http://pinvoke.net to get a little help getting started. 请参阅http://pinvoke.net,以获取有关入门的帮助。

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. 直到最近还完全不可能,但是我认为3.x版本在某种程度上已经开始成为可能。 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. 结果是,如果您以.net 2.0为目标,而其他人已经将.net 1.0作为其浏览器扩展的一部分加载,则您会迷失方向。 In general IE and the Windows Shell don't support managed extensions. 通常,IE和Windows Shell不支持托管扩展。 This .net app MIME filter stuff may be a notable exception, but be aware that there may be potential issues. .net应用程序MIME过滤器内容可能是一个明显的例外,但请注意可能存在潜在问题。

"ActiveX control (created using a .Net language)" and ".NET applet" are both slang for ".NET assembly hosted in IE". “ ActiveX控件(使用.Net语言创建)”和“ .NET applet”都是“ IE中托管的.NET程序集”的语。

In fact, .NET assemblies can be hosted in a variety of applications. 实际上,.NET程序集可以托管在各种应用程序中。 See: 看到:

Creating a Host to the .NET Common Language Runtime 为.NET公共语言运行时创建主机

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. ActiveX控件没有与.NET小程序相同的安全限制,根据您想做什么可能是有利还是不利。 .NET applets are in general easier to develop, ActiveX you create with VB6 or C++. .NET applet通常更易于开发,使用VB6或C ++创建的ActiveX。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM