TT Thanks for the response. I am familiar with the ExplodeToOwnerSpace related to a block reference but I didn't see that option for an Entity like polyline unless I am doing something wrong.
Sorry, you're right. I never noticed that it was only implemented for BlockReference (it should be implemented for anything that can be exploded, as it's just a simple automation of what you're doing with Expode() - an incorrect assumption on my part).
In any case, I trust that the problem was not clearing the DBObjectCollection after each iteration.
You can handle it in two ways. One is to just call Explode() on as many polylines as you like, passing the same DBObjectCollection into each call, and let the new entities accumulate there, and once you're done exploding, you can just add everything in the DBObjectCollection to the database.
However, one dangerous aspect of your code is that it doesn't ensure the DBObjectCollection is disposed (including if the code fails before all the objects have been added to the drawing), which could lead to crashing AutoCAD. You should put the DBObjectCollection under control of using() to be sure it gets disposed.