Article ID: 316138 - View products that this article applies to.
This article has been archived. It is offered "as is" and will no longer be updated.
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
The problem occurs if all of the following conditions are true:
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:
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
Steps 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.
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:
(https://support.microsoft.com/kb/316180/EN-US/ )FIX: System.NullReferenceException Error if You Assign a TreeView Node Tag Property
Article ID: 316138 - Last Review: January 11, 2015 - Revision: 6.0