Article ID: 186273 - Last Review: March 3, 2005 - Revision: 3.1

BUG: AV Running VB-Built Component in Multi-Threaded Environment

This article was previously published under Q186273

On This Page

Expand all | Collapse all

SYMPTOMS

When running an apartment model ActiveX DLL that is created in Visual Basic in a multithreaded environment such as Microsoft Internet Information Server (IIS) or Microsoft Transaction Server (MTS), COM+, Internet Explorer, ActiveX EXEs, and so on, the DLL fails periodically with an access violation (AV).

RESOLUTION

The following steps may be used to change the DLL to avoid the problem. This may not resolve the issue in all cases.

Step-by-Step Example

  1. Add a class module to the project.
  2. Set the name of the class to clsEmpty.
  3. Set the Instancing property of the class to 2-PublicNotCreatable.
  4. In Project Properties, set the Start Up Object to Sub Main.
  5. Add a BAS module, or put the following in an existing BAS module in the project:
          Public gEmpty As clsEmpty
          Public Sub main()
             Set gEmpty = New clsEmpty
          End Sub
    
    					
  6. Save the project and recompile.

STATUS

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

REFERENCES

For additional information on errors when using an ActiveX DLL created in Visual Basic 5.0 that contains a For... Each loop that iterates through a Visual Basic collection, click the article number below to view the article in the Microsoft Knowledge Base:
183164  (http://support.microsoft.com/kb/183164/EN-US/ ) FIX: For..Each Loop in ActiveX Component Causes Errors
For additional information on threading issues with DLLs created in Visual Basic 6.0, click the article number below to view the article in the Microsoft Knowledge Base:
264957  (http://support.microsoft.com/kb/264957/EN-US/ ) PRB: Visual Basic DLL Has Memory Leaks and Crashes in COM+ If 'Retain In Memory' Is Not Set

APPLIES TO
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Studio 97 Service Pack 3
  • Microsoft Visual Studio 97 Service Pack 1
  • Microsoft Visual Studio 97 Service Pack 2
Keywords: 
kbbug kbpending kbtophit KB186273
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations