Select the product you need help with
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 2005Article ID: 316138 - View products that this article applies to. This article was previously published under Q316138 On This PageSYMPTOMS 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:
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: STATUSMicrosoft
has confirmed that this is a problem in the Microsoft products that are listed
at the beginning of this article.
MORE INFORMATIONSteps to Reproduce Behavior
If a variant type variable is declared as Public in a class module, Visual Basic implicitly creates Let, Get, and Set accessor methods for this property. The scenario described in this article also applies to ActiveX controls that are used through COM Interop. The resolution to the problem is the same, but the error message that you receive may be different. When you work with an ActiveX control, the error message returned is a NullReferenceException. REFERENCES For additional
information about a similar scenario that uses an ActiveX control, click the
following article number to view the article in the Microsoft Knowledge Base: 316180
(http://support.microsoft.com/kb/316180/EN-US/
)
FIX: System.NullReferenceException Error if You Assign a TreeView Node Tag Property
Properties | Article Translations |


Back to the top








