`
cuteyangqiang
  • 浏览: 27418 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

一篇好文,成功或未成功在客户端使用IE下载ActiveForm的都应该看(推荐)

阅读更多

为解决ActiveForm在客户端使用IE不能下载问题,在网上搜到一篇好文,建议在这方面有问题的弟兄看一看,或许会有帮助,文章对IE下载ActiveX控件的步骤和过程做了较为详细的叙述,对于已能成功下载的人来讲,也有一定帮助.

因时间较紧,没来得及翻译,敬请原谅

Diagnosing Code Download Problems

 

By Conrad Herrmann

25 July 1997

 

So you’ve just build a nifty new ActiveX control or ActiveForm, and you’re eager to test it out in the field. You type in the information into the Delphi’s Web Deployment options dialog and select the Web Deploy command. Then you go to your coworker’s machine—one on which neither your control nor Delphi have ever been installed—and you go to the test web page Borland’s deployment Wizard generates. After a second or two, your heart jumps as you see the magic words appear:

 

Delphi ActiveX Test Page

You should see your control appear below this line:


 

 

A bit more crunching, and the screen looks like this:

 

 

 

You’ve just been given the Big Red X—an indication that the Internet Explorer was unable to download or create your control. What happened, and how can you fix it?

Any number of errors could have occurred, but Internet Explorer suppresses all the error messages making it frustratingly difficult to diagnose failures. This is a usability feature.

 

The idea is that the Internet Explorer shouldn’t pop up error messages that the user isn’t capable of dealing with anyway, and most end-users can’t tell the difference between an Authenticode security violation and the Start button. So, your control’s users will be happy and ignorant—who cares if you get a bald patch prematurely?

This paper presents an overview of the code download process Internet Explorer uses to retrieve and install your control, and presents a diagnostic schema for analyzing what’s wrong in your installation.

 

The Download Process

 

In order to create your control in the web browser, Internet Explorer must hav received an HTML file containing an <OBJECT> tag. This tag contains parameters that dictate the first steps in the download process.

For example:

 

<OBJECT
  classid="clsid:29D37F03-F02F-11D0-ACB2-0080C7316F20"
       codebase="http://www.xyz.com/MyControl.ocx#version=1,0,1,0"
       width=350
       height=250
       align=center
       hspace=0
       vspace=0

</OBJECT

The #version part of the tag is optional—if missing, it means "any version will do." The version tag must not appear if the client is the Netscape Navigator with the NCompass ActiveX plugin.

On the web server, there will be a file called MyControl.htm (many servers are case sensitive) , which has been stamped with a version tag (presumably 1.0.1.0), and which can create an ActiveX control with the specified ClassID. The first thing Internet Explorer does is to determine if the specified ClassID is already installed on the client machine. If it is, IE will check to see if the installed version matches the requested version. If the local version matches the version requested in the HTML, IE will simply use the local copy to create the control.

If the version number requested by the HTML page is newer than the one currently installed, or the ClassID is not yet installed, IE knows it must download and install the codebase before it can create the control.

 

Download and Install Steps

 

Downloading and Installing the codebase involves three basic steps:

  1. Copy the code base onto the local machine’s Windows/OCCache directory or a subdirectory of it.
  2. Check the code signature of the codebase, and
  3. Install the codebase.

If this process completes successfully, the machine should have a correctly registered OCX library from which the control can be created.

 

Copying the codebase

 

The first step, copying the control to the local machine, will be done by attempting to retrieve the file by the mechanism that the codebase URI specifies. If the URI says use HTTP(the default), then IE will use HTTP to download the control. You can also specify FTP, or FILE URIs.

This step can fail in a nuber of ways—if the remote server can’t be found, if the local disk is out of disk space, if the codebase name is spelled incorrectly (remember, many servers are case-sensitive), etc.

You can simulate this step by typing the URI into the IE address box. IE should respond with a dialog that says "Do you want to Open It or Save It?"—if you choose Save It and type /windows/occache as the directory, then this should yield exactly the same results. In the case of a connection failure or File not Found error, you will know that the URI path points to a server or a file that can’t be found. If this happenes, you may have forgotten to deploy your file to the server, or you may have typed the codebase’s URI incorrectly.

This step is the only step that gives you visual feedback, and it only does so if you’ve got a quick eye or a slow modem. When IE is downloading the codebase, you’ll see the IE’s download-progress meter (in the status bar) moving from left to right. If the status meter stays at 0%, then there is probably a connection problem. If the progress meter moves all the way across to the right, then the codebase probably was correctly copied to your machine, and the problem lies at a later stage.

One problem that often happens if you’re debugging and testing on your development machine is that you’ve left the control open in the IE browser. While your control is running, the DLL file itself is locked, so the code download process will not be able to overwrite this file. Remember that IE caches the last few pages you looked at, so even if the current page isn’t the one with your ActiveX on it, you might still have the OCX locked. Exiting IE is the only sure way to know that IE releases the lock on the DLL file.

 

Checking Authenticode Signature

 

In the second step, IE checks the code signature of your control. The kinds of errors that can occur depend on the security settings in your IE installation. If you have security set to High, IE will refuse to install the control if it hasn’t been code-signed, and will fail silently. If security is set to Medium, IE will show a warning dialog that reads "This component has not been digitally signed by its publisher. Do you wish to continue?" When security is set to low, IE will not check for a code signature at all, and will proceed to the Installation phase.

When security is set to Medium or High, and IE validates the code signature on your codebase, it will display the telltale certificate dialog which indicates it was able to verify the certificate. This dialog allows you to summarily accept all code from the specified vendor, and if the vendor already appears on this list then the certificate dialog won’t be shown.

If you’re working with unsigned controls, setting security to Medium rather than low can give you a useful piece of information about what’s happening, if you’re working with an unsigned control. If the "This component has not been digitally signed by its publisher" does not appear, the control’s codebase was not downloaded successfully—either because IE failed to download it, or because IE decided it didn’t need to be downloaded.

There also can be problems with code signature verification if you have not upgraded to Authenticode 2.0. You should make sure to upgrade your development machine to Authenticode 2.0 at the Microsoft web site.

Success? Failure? Which is it?

 

Telling whether the second step (Authenticode) succeeded or not can sometimes be difficult because there are situations where both success and failure proceed silently. The two cases where success announces itself are:

  1. Medium security setting, unsigned control, yields the "unsigned control" dialog box.
  2. Medium or high security setting, no summary accept from your vendor, yields the certificate dialog.

 

 

Installing the codebase

 

The third step is installing the codebase that was just downloaded to your machine’s WINDOWS/OCCACHE directory. How the codebase is installed depends on which kind of codebase you have. The type of codebase is determined by the CODEBASE tag in the OBJECT command. If the file is a DLL file (usually with extension .OCX), then it is the entire codebase. If the file is a .CAB file, then the codebase contains multiple files that are contained in the CAB file. If the file is a .INF file, then the .INF file describes a list of other files that make up the codebase, and where these can be found.

If the codebase is simply a DLL/OCX file, the installation only requires loading the DLL and then calling the DllRegisterServer function in the DLL. If this function succeeds, IE can then try to create the control.

There are two common points of failure in this scenario, both of which fail silently. The first is if the DLL can’t be loaded on the client machine using LoadLibrary . This usually happens if the DLL is dependent on other files, such as library DLLs, Delphi packages, or even specific system DLLs that aren’t available on the client machine. Load failure can also occur if the DLL file was corrupted. If the DLL fails to load properly, no code in the DLL will execute, which means the DLL cannot be debugged in the debugger.

Failure can also occur if the DLL can be loaded but it fails to initialize. This usually isn’t a configuration problem, but probably happens because one of your units’ initialization sections throws an exception. You can determine if your DLL gets loaded correctly by setting a breakpoint at one of your units’ initialization section. If the DLL gets loaded, the initialization sections will be executed, and you can step through their execution until you find the failure.

Another failure can occur if your control cannot register itself correctly. This can happen if your control doesn’t export DllRegisterServer , or if this function fails. Since most Delphi ActiveX controls start with code generated by the Wizard, the first of these is unlikely. There are number of reasons why registering the DLL server might fail, but a common one on NT is caused by inadequate user rights. Each object is registered by its factory (the object you created in the initialization section of your control’s implementation unit), so if any of the factories fail to register the entire server will fail to register. If you use custom factory classes, you might want to check that these classes don’t fail on the user’s machine.

 

Creating the control

 

Once your control is correctly installed and registered, IE tries to create an instance of the control. If you’e tested your control locally on your development machine, it’s unlikely that this step will fail, but there are a few errors that will make you just say DOH!

The first is that the ClassID in your HTML file may be incorrect. Up until this point, the ClassID specified in the HTML has played no part in the code download process, so an incorrect ClassID would only show a failure in this phase.

Various low-memory or low-resource conditions might cause your control to fail to create itself as well. The object creation will fail if your COM object fails to construct itself. If you’re building an ActiveX control, your control’s Create or Initialize method might throw an exception or otherwise indicate failure (this is a condition you can debug).

 

Putting the control in the HTML page

 

After the control is created, there are still conditions that might fail the installation of your control into the browser’s HTML page. If your <OBJECT> tag contains PARAM statements for your object, the control must be marked safe for initializing in order for IE to allow it to appear on the page, if your security setting is Medium or High. If the HTML tag declares your object available for scripting on the page, IE checks that the control is safe for scripting . In either case, if the control is appropriately marked, and security is Medium or High, the control won’t appear.

Note that the Delphi ActiveX Class Hierarchy doesn’t support the PARAM tag by default—this is a feature you must implement on your control yourself. Nevertheless, it’s not uncommon for a beginner who doesn’t know this to supply a PARAM tag on the HTML page. Because the control is also not marked safe for initializing by default, supplying the PARAM tag will suppress your object’s installation on the HTML page even if the object doesn’t have the means to receive these PARAMs through IPersistPropertyBag.

If you have a script that refers to your control, and the control wasn’t marked safe for scripting , the script will probably give you a runtime error when it tries to access the (now nonexistent) control on the page.

 

Conclusion

 

The trick to diagnosing the failure of any complex process is to recognize the signs of success or failure of each step in the process. While IE intentionally suppresses most of these clues, it leaves you with just enough information to be able to diagnose what it’s doing.

The attached flowchart summarizes the code download process, and can help you to diagnose a failure in your download.

 

 

Code Download Flowchart

 

Use this flow chart for diagnosing download errors.

分享到:
评论

相关推荐

    简单的activeform例子

    在IT行业中,ActiveForm是一种在早期的Web应用程序开发中广泛使用的技术,特别是在使用Microsoft的ASP(Active Server Pages)时。ActiveForm是微软.NET框架的一部分,它允许开发者将Windows Forms控件嵌入到Web页面...

    使用delphi XE创建ActiveForm成功经历

    这一步骤与Delphi 7中的操作方式有所不同,在Delphi 7中可以直接创建ActiveForm,而在Delphi XE中则需要先创建一个Type Library项目来支持ActiveForm的开发。具体步骤如下: - 打开Delphi XE IDE,选择“New”-&gt;...

    Delphi ActiveForm实例

    在描述中提到的"实例可用,并通过测试"意味着这是一个已经成功实现并经过验证的ActiveForm应用,用户可以下载并研究其工作原理。 在Delphi中,创建ActiveForm的过程通常包括以下步骤: 1. **创建Delphi Form**:...

    用delphi开发的聊天软件,基于Web并结合了网页中嵌入ActiveX技术,就是Delphi的ActiveForm

    在聊天软件的上下文中,通过ActiveForm,开发者可以创建一个在用户的Web浏览器中运行的聊天客户端,提供类似桌面应用的交互体验。 这个聊天软件的工作原理可能如下:首先,服务器端负责处理聊天的逻辑,包括消息的...

    C++ Builder 6制作ActiveForm源码

    ActiveForm是一种技术,它允许开发者将Visual Component Library (VCL)组件封装到一个ActiveX控件中,使得这些控件可以在其他支持ActiveX的环境中如Visual Basic、HTML页面或者其他的C++ Builder项目中使用。...

    delphi2010和delphi xe中创建和发布ActiveForm的方法

    ### Delphi2010与Delphi XE3中创建及发布ActiveForm的详细方法 #### 一、创建ActiveForm 在Delphi2010和Delphi XE3中创建ActiveForm涉及到以下步骤: ##### 1. 创建ActiveLibrary工程 - **第一步:** 打开Delphi...

    ActiveForm 示例,Delphi 开发的源代码.rar

    ActiveForm是Delphi中的一个特性,它允许开发者将一个Windows Forms组件与Internet Explorer(IE)控件集成,实现所谓的“Web Activex”或“WebBrowser”应用。这种技术主要应用于90年代末和2000年初,当时ActiveX...

    Yii2创建表单(ActiveForm)方法详解

    在ActiveForm中,可以利用`ActiveForm::errorSummary()`方法在表单顶部显示所有错误,或在每个字段中使用`validate()`方法进行验证。 ### 关于每个field容器样式的属性 `fieldConfig`是一个重要的属性,可以指定...

    ActiveForm 示例,基于Delphi的

    在IT领域,Delphi是一种非常强大的面向对象的编程环境,尤其在Windows应用程序开发中具有广泛的应用。本示例聚焦于“ActiveForm”,它是Delphi中一个重要的概念,用于创建动态的、交互性强的用户界面。在Delphi中,...

    ActiveForm电子签名示例

    自己制作ActiveForm电子签名的演示文档,具体步骤察看压缩包的Word文档。 先要有工具包,包括以下几个软件: makecert.exe 制作cer格式的证书,即X.509证书,同时可以创建私钥 cert2spc.exe 将cer格式证书转换成...

    delphi进行ActiveForm编程演示程序

    在本示例中,我们关注的是"ActiveForm编程",这涉及到创建ActiveX控件,这是一种可以在不同应用程序间共享的组件。ActiveX Form是特定类型的ActiveX控件,它是一个用户界面元素,可以在多种支持ActiveX技术的环境中...

    更新多层应用程序数据.rar_delphi web_web服务器_分布式

    本程序在开发完ActiveForm后,要使用“Project/WebDeploy” 菜单将其分发到Web服务器中,以便使客户端可以下载。 同时,还要通过“Project/Web Deploy Options”来 正确设置位置信息。 要在分布式应用系统中更新数据...

    使用Delphi 6实现BS模式下的复杂程序

    Delphi 6对HTML和ActiveX的开发都有很好的支持,尤其是ActiveX,使得开发者可以构建在IE浏览器中运行的Delphi应用程序,即ActiveForm。 ActiveForm是Delphi提供的一种特殊类型组件,它可以在浏览器中执行,就像在...

    YII2.0之Activeform表单组件用法实例

    在PHP代码中,我们使用`ActiveForm::begin()`方法来开始一个表单,指定表单的属性如`action`(表单提交的URL)和`method`(表单的提交方式,通常是`POST`或`GET`): ```php $form = ActiveForm::begin(['action' =...

    yii2 modal弹窗之ActiveForm ajax表单异步验证

    在Yii2框架中,实现ActiveForm的ajax表单异步验证,主要涉及的技术点包括:ActiveForm组件、ajax验证、modal弹窗、以及客户端和服务端的数据交互。本文将针对这些知识点进行详细解读。 ### 一、ActiveForm组件 在...

    Yii2实现ActiveForm ajax提交

    首先,要实现ActiveForm的AJAX提交,需要在ActiveForm组件中启用AJAX验证。这可以通过设置ActiveForm的属性来完成。在表单开始标签中,可以设置`enableAjaxValidation`为true,并且指定一个URL,该URL用于AJAX验证...

    yii2-formwizard:一个Yii2插件,用于使用yii \ widgets \ ActiveForm和\ yii \ db \ ActiveRecord创建步进式表单或表单向导

    一个Yii2插件,用于使用yii\widgets\ActiveForm和\yii\db\ActiveRecord创建步进式表单或表单向导,它使用来创建使用3个内置和3个其他主题的表单界面,此外,您还可以创建自己的表单也有自己的定制主题。 注意:它...

    VB窗口属性中文对照表

    - **作用**:设置此属性可以自动更新图像或图形对象的显示,使其在移动或修改时立即刷新。 ##### AutoSize - **中文含义**:控制对象自动调整大小。 - **作用**:当此属性为真时,控件会根据其内容自动调整其大小。...

Global site tag (gtag.js) - Google Analytics