Microsoft KB Archive/221541

= FIX: Failed to Mark Safe for Scripting Using Visual Basic PDW =

Article ID: 221541

Article Last Modified on 9/5/2006

-

APPLIES TO

 Microsoft Visual Basic 6.0 Learning Edition, when used with:  Microsoft Windows 95

 Microsoft Windows 98 Standard Edition  Microsoft Visual Basic 6.0 Professional Edition, when used with:  Microsoft Windows 95

 Microsoft Windows 98 Standard Edition</li></ul> </li> Microsoft Visual Basic 6.0 Enterprise Edition, when used with:  Microsoft Windows 95</li></ul>

 Microsoft Windows 98 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q221541

<div class="symptoms_section">

SYMPTOMS
When an ActiveX control is marked as Safe for Scripting and Safe for Initialization when packaging it using the Package and Deployment Wizard (PDW), depending on your security settings for unsafe controls, Internet Explorer may still identify the ActiveX control as unsafe, or it may display an "Object Required" error.

<div class="cause_section">

CAUSE
The ActiveX control is not marked as Safe for Scripting and Safe for Initialization in spite of choosing these options when packaging the control using the Visual Basic 6.0 Package and Deployment Wizard.

This is because the [AddToRegistry] section is missing from the INF file generated by the Visual Basic 6.0 PDW, and this section usually contains the registry entries that mark the controls as safe.

<div class="resolution_section">

RESOLUTION
You can manually add the [AddToRegistry] section in your INF file by following the steps listed below. <ol> Create your ActiveX Control.</li> Package your control using the Package and Deployment Wizard.</li> Before you deploy the package, go to the folder for that package in Windows Explorer</li> There should be a support directory under that package. Open the Xxx.inf file under this Support directory with Notepad.</li>  Paste the following code at the end of the file. [AddToRegistry] HKLM,"SOFTWARE\Classes\CLSID\{04CD5348-D028-11D2-82A6-00C04FB9D847}\Implemented Categories\{7DD95802-9882-11CF-9FA9-00AA006C42C4}" HKLM,"SOFTWARE\Classes\CLSID\{04CD5348-D028-11D2-82A6-00C04FB9D847}\Implemented Categories\{7DD95801-9882-11CF-9FA9-00AA006C42C4}" </li> Save the file with the same name.</li> Run the .bat file in the Support folder, which is created by the PDW. This bat file will re-create your .cab file with the new changes.</li> Now you can use the PDW to deploy the package to the appropriate Web server location.</li></ol>

The preferred method for marking a control as safe is to implement the IObjectSafety interface. For information on implementing theIObjectSafety Interface, please see the following:

182598 HOWTO: Implement IObjectSafety in Visual Basic Controls

http://msdn.microsoft.com/vbasic/downloads/download.asp?ID=030

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Visual Studio 6.0 Service Pack 3.

For more information about Visual Studio 6.0 Service Packs, please see the following articles in the Microsoft Knowledge Base:

194022 INFO: Visual Studio 6.0 Service Packs, What, Where, Why

194295 HOWTO: Tell That Visual Studio 6.0 Service Packs Are Installed

<div class="moreinformation_section">

Steps to Reproduce Behavior

 * 1) Create a simple ActiveX Control with at least one method or property.
 * 2) Package it using PDW with the Internet Package option.
 * 3) Set it as Safe for Scripting and Safe for Initialization in the PDW.
 * 4) Deploy the Package to Web Server using the PDW.
 * 5) From the Tools menu, click Internet Options. Click the Security tab. Change the following settings:
 * 6) * Enable - download unsigned ActiveX Controls
 * 7) * Enable - initialize and script ActiveX control mark for safe
 * 8) * Prompt - initialize and script ActiveX control not mark for safe
 * 9) Insert your control in your HTML page with an Object tag and set the codebase point to your .cab file. Script your control by setting/getting the property or calling its methods in the window onload event
 * 10) From your client browser, navigate to your HTML page.
 * 11) You will be prompted with the message that the control is not safe for scripting and initialization even though your security settings are set to enable for scriting and initialization safe controls. This shows that your control has not been marked safe as expected.

Steps to Reproduce Behavior
<div class="references_section">