FIX: For..Each Loop in ActiveX Component Causes Errors (183164)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
This article was previously published under Q183164 SYMPTOMS
When using an ActiveX DLL created in Visual Basic, you may receive one of
the following errors if the ActiveX component contains a For..Each loop
that iterates through a Visual Basic collection:
Run-time error '48':
Error in loading DLL
Run-time error '-2147319765 (8002802b)':
Automation Error
This problem occurs when a For..Each loop is executed in an ActiveX DLL.
For..Each loops elsewhere do not exhibit this problem.
CAUSE
This problem typically occurs after calling the DLL at least twice. The
first call into the DLL does not execute code that uses a For..Each loop
but the second call does. The error occurs during the second call. See the
"Steps to Reproduce Behavior" section below for more information.
RESOLUTION- Use a For..Next loop in place of the For..Each loop.
-or-
- Create your own collection class, an example of which can be found in
the Visual Basic Books Online. Refer to the topic "Creating Your Own
Collection Classes."
-or-
- If your DLL is running in a multithreaded environment like Internet Information Server
(IIS) or Microsoft Transaction Server (MTS), please see the following article here in the Microsoft Knowledge Base:
186273 BUG: AV Running VB-Built Component in Multi-Threaded Environment
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem has been corrected
in Microsoft Visual Basic 6.0.
NOTE: If your DLL is running in a multi-threaded environment, you must still complete the steps provided in the following article in the Microsoft Knowledge Base: 186273 BUG: AV Running VB-Built Component in Multi-Threaded Environment
REFERENCES
For additional information, please see the following article in the
Microsoft Knowledge Base:
178777
: PRB: ASP Returns "Error in Loading DLL" with VB Component
Modification Type: | Major | Last Reviewed: | 11/18/2003 |
---|
Keywords: | kbBug kberrmsg kbfix kbVBp600fix KB183164 |
---|
|