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

原创 2002年04月04日 09:15:00

为解决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.

 

 

 

 

 

《学术研究,你的成功之道》 读书笔记

这本凌晓峰和杨强老师写的,《学术研究,你的成功之道》,干货满满的探讨和指导了与研究有关的许多事情。读完之后,受益匪浅,诚心推荐给大家。 一些读书笔记,记录在这里。 第一章 兴趣是研究的动力,创新...
  • Wiking__acm
  • Wiking__acm
  • 2016年08月26日 20:25
  • 957

.NET Winform Click once 发布出错,应用程序验证未成功,无法继续解决办法

Click once 发布出错,应用程序验证未成功,无法继续 请各位朋友帮帮我吧,使用微软的ClickOnce技术发布软件,在原来的系统中正常使用,移交到客户的系统时出现问题 应用程序验证未成功,无...
  • qq798833488
  • qq798833488
  • 2016年07月30日 19:58
  • 1714

.net mvc4 + ajaxfileupload.js 解决IE浏览器中弹出下载对话框问题

学习解决ajaxfileupload在IE下面出现弹出框为另存为的问题
  • ybb350680013
  • ybb350680013
  • 2014年09月02日 09:54
  • 1918

libevent异步TCP连接,判断是否连接成功

 参考: http://stackoverflow.com/questions/16074981/how-to-check-if-connection-is-established-w...
  • litao0813
  • litao0813
  • 2014年04月29日 16:30
  • 2038

在客户端配置TNS测试报错ORA-12170:TNS:连接超时

在Red Hat Enterprise Linux Server Releae 5.5 成功安装ORACLE 10g 后,在客户端配置TNS后,测试是否可以连接到数据块服务器,结果报错: ORA-12...
  • e_wsq
  • e_wsq
  • 2014年03月28日 00:45
  • 796

关于visual studio安装插件ClaudiaIDE 未能加载成功

在安装 ClaudiaIDE后,visual studio中会出现炫酷而又帅气的背景。但是有些小伙伴可怜的安装上了却在:工具—选项— ClaudiaIDE  中不能加载出来。本人在度娘寻找了一下午以...
  • u013196740
  • u013196740
  • 2016年04月19日 15:45
  • 2332

程序提示安装失败,或者安装未成功处理

1 随着app手机的普及,很多应用存在下载安装后提示各种错误,一下是个人遇到中的几点安装失败,仅作参考: ① 出现内存不足,请重新安装。 如果用户出现这种问题,解决方案有三种      1...
  • xiangyihu
  • xiangyihu
  • 2016年01月03日 17:48
  • 1636

iOS https证书到AFN3.x配置再到成功访问

iOS https证书到AFN3.x配置再到成功访问
  • srxboys
  • srxboys
  • 2016年12月29日 13:27
  • 212

上传文件 IE不兼容的问题[提示下载保存]

转自:http://blog.csdn.net/u012116457/article/details/49531863 在使用Extjs做文件上传时,其他浏览器没有问题,但IE却一个...
  • Dorothy1224
  • Dorothy1224
  • 2017年05月10日 18:58
  • 559

在IE中使用ActiveX控件,需要使用HTML中的标志是<OBJECT>,该标记几个重要的参数特性有:

在IE中使用ActiveX控件,需要使用HTML中的标志是 1.ID:为控件提供一个标识名称,为HTML代码提供一种访问该控件的入口。 2.CLASSID:是该控件唯一的UID,告诉IE装入哪个对...
  • guorun18
  • guorun18
  • 2015年12月15日 10:32
  • 2325
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:一篇好文,成功或未成功在客户端使用IE下载ActiveForm的都应该看(推荐)
举报原因:
原因补充:

(最多只允许输入30个字)