Don’t use VB Registry functions in WebClasses and ASP components

Don’t use VB Registry functions in WebClasses and ASP components

Here’s a scenario that might be familiar to you:

  • You create a WebClass or a regular COM component that will be invoked from within an ASP application
  • The application uses VB’s built-in registry functions, such as DeleteSetting, SaveSetting, GetSetting, or GetAllSettings
  • Everything works when you debug the application inside the IDE
  • However, the application raises a runtime error when you compile it and use in the production system
Because the compiled application doesn’t run in the interactive Windows desktop, you must go to the system Event Viewer to see the error message, which is Run-time error ‘5’: Invalid procedure call or argument.

This isn’t a bug, rather it’s a consequence of how those registry functions use the registry. Visual Basic 6.0 Webclasses and ASP components run under the Internet Information Server service. SaveSetting, GetSetting, DeleteSetting, and GetAllSettings use registry keys in the HKEY_CURRENT_USER registry subtree, but the IIS service can’t access the HKEY_CURRENT_USER registry subtree, and any attempt to do so will raise an error.

You can work around this problem by reading and writing to another area of the registry, such as HKEY_LOCAL_MACHINE or HKEY_USERS. You can use other functions in the Code Bank to do so.

See also  Does It Make Sense to Splurge on a Laptop?

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist