ReplaceComponents Method (IAssemblyDoc) Crashing Solidworks

I am using Solidworks 2012 (SP4) and when I replace a component, then reselect the new replaced component, then try to use the ReplaceComponents Method, It crashes out Solidworks.

My Error Handler shows the following:

Message: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

StackTrace:

   at SolidWorks.Interop.sldworks.IAssemblyDoc.ReplaceComponents(String FileName, String ConfigName, Boolean ReplaceAllInstance, Boolean ReAttachMates)

   at BascoMenus.Register.ReplacePartSequenceCallback() in ...

What should I do to protect SolidWorks from crashing if a user decides to try to replace a component a second time?

This does not happen if I use strickly the SolidWorks "Replace Components" without the programming but the API Programming will crash SolidWorks.

Thanks,

Greg

SolidworksApi macros