BUG: Late-bound calls to overloaded methods of a structure instance do not work as expected in Visual Basic .NET (814603)
The information in this article applies to:
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic .NET (2002)
SYMPTOMSIn Microsoft Visual Basic .NET, late-bound calls to
overloaded methods of a structure instance do not work as expected. For
example, if you call an overloaded method in a structure or in a class, the
method that is called depends on the arguments that are passed as parameters to
the method. In a late-bound call, the argument is an object. Based on the boxed
value of the argument, the appropriate method is called at run time. However,
you do not receive the same output as you receive for early bound arguments.
The output you receive depends on the default values that the members of the
structure have.CAUSEThis problem occurs because of late-bound resolution. When a
late-bound call is made to a method in the structure, the structure is boxed
before passing to the late-bound helpers. In this process, a temporary copy of
the structure is created. The instructions for the method are carried out in
the temporary boxed structure instead of in the actual structure instance. The
temporary structure goes out of scope when the method execution is completed.
Executing the method does not affect the actual structure
instance.WORKAROUNDTo work around this problem, use one of the following
methods:
- Type-cast the data to the required data type while you pass
the data as a parameter to the method.
- Use early binding. To do this, declare the parameters with
the actual datatypes instead of with late binding (declare the parameters as
objects).
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.REFERENCES
For more information about overloading methods, click the following article number to view the article in the Microsoft Knowledge Base:
311330
INFO: Overloading methods in Visual Basic .NET
Modification Type: | Minor | Last Reviewed: | 2/3/2006 |
---|
Keywords: | kbvs2005swept kbvs2005doesnotapply kbvs2002sp1sweep kbProgramming kbCompiler kbbug KB814603 kbAudDeveloper |
---|
|