BUG: You receive a "Type mismatch" error message when you assign a value type variable to a property through COM InterOp in Visual Basic .NET or in Visual Basic 2005 (316138)
The information in this article applies to:
- Microsoft Visual Basic .NET (2002)
- Microsoft Visual Basic .NET (2003)
- Microsoft Visual Basic 2005 Express Edition
This article was previously published under Q316138 SYMPTOMS When you assign a value to a property of a Component Object
Model (COM) object in .NET, you may receive the following error message when
you run your application: An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in
InterOpDemo.exe
Additional information: Type mismatch
CAUSE The problem occurs if all of the following conditions are
true:
- You are using the COM object in early bound
mode.
- The property in the COM object has both Set and Let methods.
- You are trying to pass a value type variable to that
property.
In early bound mode, Microsoft Visual Basic .NET and Visual Basic 2005 always call the Set method of the property if it is available. If you want to call
the Let method, you must explicitly specify it. RESOLUTION Explicitly tell the compiler to use the Let method. For example, you can use code similar to the following to
tell the compiler to use Let instead of Set:
Dim Obj1 As New InterOpVB6.Class1()
Obj1.let_Var1("abc")
STATUSMicrosoft
has confirmed that this is a problem in the Microsoft products that are listed
at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 1/31/2006 |
---|
Keywords: | kbvs2005swept kbvs2005applies kbvs2002sp1sweep kbbug kbpending KB316138 |
---|
|