BUG: "Too Many Local, Nonstatic Variables" Error Message
This article was previously published under Q179140 On This PageSYMPTOMS
When compiling an application that calls functions or subroutines in a DLL
and that passes large User Defined Types to the DLL, you may receive the
following error message:
Too many local, nonstatic variables
CAUSE
The above error is the result of a bug in the Visual Basic compiler when
allocating memory for passing User Defined Types (UDTs) to functions or
subroutines in DLLs. The error may occur when this amount exceeds
approximately 64KB.
RESOLUTION
You can work around this problem by changing the way that such UDTs are
passed to the DLL. When you pass a UDT to a DLL, you are actually passing a
pointer to the first memory location of the UDT. Another way to pass this
pointer is by copying the UDT to a Byte array and passing the first element
of the Byte array by reference. NOTE: You will need to calculate the size of this Byte array manually, taking into consideration the issues relating to byte-alignment. For more information regarding byte-alignment, refer to Section 6 of the VB5DLL.DOC document located in the Tools\Docs folder of the Visual Basic CD-ROM. Because the Visual Basic run-time library converts the strings from UNICODE to ANSI when using the CopyMemory function below, you should only allocate 1 byte for each character in your fixed-length strings. Assuming you have the following UDT and Declare statement for your DLL:
Follow these steps to implement a workaround to the problem:
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. We are researching this bug and will post
new information here in the Microsoft Knowledge Base as it becomes
available.
MORE INFORMATIONSteps to Reproduce Behavior
REFERENCES
For additional information on calling subroutines and functions in DLLs,
please see the following document: VB5DLL.DOC, Visual Basic 5 CD-ROM (Professional and Enterprise Editions Only), in the following folder ...\TOOLS\DOCS\. APPLIES TO
| Article Translations
|

Back to the top
