HOWTO: Test Your ActiveX Documents (.VBD)Last reviewed: November 10, 1997Article ID: Q168428 |
The information in this article applies to:
SUMMARYVisual Basic 5.0 introduces the ability to create ActiveX documents (.VBD files) for use with Internet browsers. This article will walk you step-by-step through creating a simple ActiveX document, show you how to test it while within the Visual Basic 5.0 development environment, then test it outside of the Visual Basic 5.0 development environment. The power of the Internet is that potential users from all of the world will be able to hit and view your page. (The same applies to the Intranet, although on a smaller scale; users all over your corporation may be able to hit and view your web page). With this in mind, different users will have different configurations and different software installed on their PC's. When your ActiveX page is hit by an Internet user, Internet Explorer searches the local PC for all of the files required by the document. If a required file is present and has a version equal to or greater than the version you require, it uses it. If a file is missing or is older than the version required, Internet Explorer prompts the user to install the file and will proceed to do so. While testing an ActiveX document, a problem occurs for developers because all of the required files are already installed onto the development machine. So how do you simulate a client's machine, one which has not been exposed to Visual Basic and the components you are using or which you've created? This article will also describe how to simulate such an environment.
MORE INFORMATIONTo begin, you need to create a simple ActiveX document for testing purposes. If you already have an ActiveX document to test, proceed to the section "Testing Your Document Using Visual Basic 5.0" later in this article.
Creating a Simple ActiveX Document
Testing Your Document Using Visual Basic 5.0The following steps assume you have Microsoft Internet Explorer version 3.00 or later installed onto your system. To obtain the latest version of Internet Explorer be sure to visit the following Web site:
http://www.microsoft.com/ie At this point, your document is ready to view with Internet Explorer. For testing purposes, Visual Basic 5.0 has created a .VBD file in the current working directory. This directory is usually where Visual Basic is installed. This file can now be viewed with Internet Explorer. "C:\Program Files\DevStudio\Visual Basic\MyTestDocument.VBD" NOTE: Your path to the .VBD file may be different, so modify the line above as appropriate. The .VBD file should open in Internet Explorer, displaying any controls you added to the document and executing any code you've added to the project, as appropriate. If this test worked, you can modify the project as desired, adding code, adding controls, etc. You may then continue to test the VBD file with Internet Explorer simply by running the project and viewing the VBD file with Internet Explorer. NOTE: The VBD file is temporary; Visual Basic will delete the file when the project stops executing.
Creating Your Internet Download SetupThe following steps take you through the creation of your Internet download setup. If you have created your own ActiveX document (rather that using the example created above), substitute your ActiveX document name where necessary.
Testing the Internet DownloadAs a developer, you may want to test the Internet Download from your own machine first. Remember, however, that because Visual Basic 5 is already installed on your machine, you know all of the necessary files are installed and the ActiveX document should load without incident. To test the document from the development machine, locate the Internet download files the Setup Wizard created. In the setup folder there will be an HTM file; if you created the example above this file will be named MyActiveXDocument.HTM. Simply double-click the file or locate it with Internet Explorer to open it. The second test you should apply to your ActiveX document is testing it from a machine without Visual Basic 5.0 installed. If you do not have such a machine available to you for testing, refer to the "Simulating a Clean Machine" section of this article. From a machine that does not have Visual Basic 5.0 installed, use Internet Explorer to locate and open the HTM file created by the Setup Wizard. IMPORTANT NOTE: Before testing the ActiveX document, be sure the safety level in Internet Explorer is set to Medium or None. If the safety level is set to High, the required files will not get downloaded and the ActiveX document will not load. To check the security level in Internet Explorer, choose Options from the View menu. From the Options window, select the Security tab, and then click the Safety Level button. If you set the Safety Level to None, all of the missing components will be installed without warning. If the Safety Level is set to Medium, the following warnings will occur: First, you will be warned that an attempt to install the CAB file is being made if you created the example above you will be prompted to install MyActiveDocument.CAB. If you respond Yes, the MyActiveXDocument.Exe and MyActiveXDocument.INF will be installed onto the client machine in the Windows\OCCache folder. Second, you will be asked if you wish to install Microsoft Automation. The Authenticode screen will display information about this component. If you respond Yes, a similar screen will warn you that the Microsoft Visual Basic 5.0 Run-time Library is going to be installed. Both of these components will be installed from the Microsoft Web site into the Windows\System folder (Windows\System32 folder on Windows NT). Third, a script warning will appear warning the user that the HTM file contains scripting code. This code is necessary in order to view your ActiveX document. These warnings are all part of the Internet Explorer's safety mechanisms. If you do not receive all of the above warnings, do not be alarmed. You may not receive a warning if a necessary component is already installed on the client machine or a security level option in Internet Explorer is set to something other than the defaults. As part of testing, you may wish to test various Internet Explorer security settings to be sure your document loads as expected under varying circumstances.
Simulating a Clean MachineAs a developer, you should test your application on various machines with varying configurations. However, if you do not have a "clean machine" (one that does not have Visual Basic 5.0 or the Visual Basic 5.0 Run-time Library installed), the steps outlined below describe how to configure a development machine so that it behaves like a clean client. These steps may also be taken to clean a client machine that may have been previously exposed to your ActiveX document, Visual Basic 5.0, or the Visual Basic 5.0 Run-time Library. WARNING: Before following the steps below to simulate a clean machine, be aware that unregistering, renaming, and deleting any of the following files could impact other applications installed onto your machine. For more information about undoing the steps provided here, see the "Restoring Your Machine" section of this article. In order to clean a machine for testing an Internet download, you must begin by unregistering the Visual Basic 5.0 Run-time Library. This step will require a copy of REGSVR32.EXE. This file may be installed onto your development machine; if it is not, it may be found on the Visual Basic 5.0 installation CD-ROM.
Restoring Your MachineOpening the HTM file as described in the last step of the previous section of this article will restore your machine to its original configuration. Internet Explorer will download and register each required file for you. However, if something should go wrong during the Internet download setup, you can reverse the changes made by restoring all of the original files and registering the necessary components. Any file deleted or renamed would need to be renamed back to its original name or restored from the Windows Recycle Bin. If a file cannot be restored from the Windows Recycle Bin, an original may be found on the Visual Basic 5.0 CD-ROM (unless the file was provided by a third party, in which case you will need to restore the file from the appropriate location). Once the necessary files have been restored, you can run REGSVR32.EXE to register those files that were initially unregistered. For example, to register the Visual Basic 5.0 Run-time Library, execute the following command from the run dialog:
REGSVR32 <Path to Windows>\System\MSVBVM32.DLLTroubleshooting This section will attempt to cover some of the possible problems you may experience with the Internet Download setup. Problem:
REFERENCESVisual Basic 5.0 Component Tools Guide, Chapter 5 "Creating an ActiveX Document" Visual Basic 5.0 Programmer's Guide, Chapter 17 "Distributing Your Applications" Keywords : AXSDKDocObjects vb5all vb5howto kbhowto Version : 5.0 Platform : WINDOWS Issue type : kbhowto |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |