SQL Server Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘information object’

InterOp interfaces must match Vtable layout for early binding to work

Symptoms
When you call a COM method through InterOp, you may receive the following error message:

An unhandled exception of type System.Exception occurred in ApplicationName.exe
Additional information: Object reference not set to an instance of an object.
Resolution
This problem may occur when the order of the methods declaration in the InterOp interface does not match the order of the Vtable layout of the COM interface (which is determined by their layout in IDL). Because you perform early binding in most cases, the order of the methods is very important in this scenario.

InvalidCastException when you bind DateTimePicker that contains a null value in Visual Basic

Symptoms
When you bind a DateTimePicker control to a data source, you may receive the following error message:

An unhandled exception of type ‘System.InvalidCastException’ occurred in mscorlib.dll
Additional information: Object cannot be cast from DBNull to other types.
Resolution
This behavior occurs if the field that is bound to the DateTimePicker control contains a null value that is represented by the System.DBNull object. The DateTimePicker control does not support the System.DBNull object.