PRB: Error 429 Using MSDN File System Object Programming Examples

Symptoms

You are distributing an application that uses one of the MSDN programming examples for the File System Object (FSO) when you are running an application after installation the following error appears:

Runtime Error '429' : ActiveX Component Can't Create Object

Cause

This error occurs because many of the MSDN code examples use late binding to the Microsoft Scripting Runtime (the component that contains the FS0.) Because late binding is used, a reference to the component (Scrrun.dll) is not required. When you use the Setup Wizard or Package and Deployment Wizard to package your application, the Wizards look at the references in the project to see which components need to be included in the package. Because there is no reference for this component, the component is not included, and the end result is an error when you attempt to create an FSO.

This problem is not specific to the FSO or the Scripting Runtime. The error can occur with any component when you use late binding. If you are using late binding, make certain that the component you are late binding to is either included with your application package or is already present on the target computer.

Resolution

The Microsoft Scripting Runtime must be installed from the Microsoft Windows Script components. The Microsoft Windows Script components are installed by a self-extracting EXE. You can redistribute this EXE with your setup package. Alternately, your customers can download and install the appropriate self-extracting EXE at following Microsoft Web site:

Status

This behavior is by design.

More Information

Steps to Reproduce Behavior

  1. Verify that the scripting runtime (Scrrun.dll) is present on your computer.
  2. Start a new Standard EXE project in Visual Basic. Form1 is created by default.
  3. Add the following code to Form1. (This code is from a MSDN example.)
    Private Sub Form_Click()
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set a = fs.CreateTextFile("c:\testfile.txt", True)
    a.WriteLine ("This is a test.")
    a.Close
    End Sub
  4. From the File Menu, save the project then chose Make Project1.exe.
  5. To verify that this works, run the EXE and click on the form. You will find a file named Testfile.txt in you root (C:\) directory that contains the text, "This is a test."
  6. Start the Package and Deployment Wizard, and build a setup package for Project1.
  7. Install the application on a computer that does not have the scripting runtime installed.
  8. Run the application, and click on Form1.
  9. You should receive Error 429.

References

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

254166 BUG: Distribution of Microsoft Scripting Runtime Library Fails
Svojstva

ID članka: 247979 - posljednja izmjena: 6. kol 2007. - verzija: 1

Povratne informacije