Knowledge base KB0201

How to use Windows subclassing when programming a .NET add-in


I have developed a .NET add-in for Microsoft Office which is using windows subclassing. My customers experience Office crashes when my add-in and another add-in (e.g., think-cell) are running.


This problem is often caused by subclassing with NativeWindow.AssignHandle / NativeWindow.ReleaseHandle.

Instead, follow Microsoft's recommendation to P/Invoke to Comctl32.dll's SetWindowSubclass and RemoveWindowSubclass.

For a detailed technical discussion and working sample code please see Microsoft's blog post