Deleting Excel file crashes Revit

I’ve made a custom node which creates a Excel file using a dll made in Visual Studio. Once the file is created I end the transaction and start a new transaction using common Dynamo nodes. I feed in the new file in Dynamo Excel and create points and curves using Dynamo. It works correctly but when I delete the Excel file from the folder it crashes Revit. This happens even after closing Dynamo.

I’m unsure where to start and how to debug this. I can send over any information that would help figure out why this is happening.

c# code used to generate Excel file:

Just in case anyone else runs into this problem. I discovered that the Excel node in Dynamo isn’t stable and will cause Revit to crash if you close Dynamo and delete the Excel file. It must be holding on to something. I could uncover what it was.

My solution was to use Bumblebee’s read excel. Which just reads the file and doesn’t actually open it. This seems to fix the problem.