I am creating a lot of Powerpoint Slides in a loop, using Interop and VB.NEt 4.0 and I have trouble solving a strange powerpoint crash.
The creation of slides works well in most cases, but sometimes Powerpoint runs into a problem of its own and stops working properly. Most of the times it just stops responding oder crashes immediately. Detecting this failure is easy, just evaluate the H_Result. But sometimes there is a more challenging failure: Powerpoint stops responding but does not throw an exception. It simply stops working until somebody manually tries to push a button in Powerpoint, which will generate an exception. But if nobody pushes this button, Powerpoint will stay frozen indefinitely. Due to this condition, my code will never have a chance to evaluate the problem. This is especially annoying if you want to create a huge number of Slides at night and it stops after Slide 50. Does anybody have an idea how to solve this problem. This whole program runs in an Backgroundworker - so maybe my main thread can ask the bgw every minute or so "are you still alive?" But how to implement this.
Below is a simple Outline of the Backgroundworkercode.
Basically, it's look like this:
Dim SlideNumber as Integer =0
Dim PowerpointHasCrashed as Boolean
Dim Slide as pptns.Slide
do while SlideNumber<ListOfSlidesTobeCreated.Count-1 and PowerpointHasCrashed =False
try
DoStuffWithSlide(ListOfSlidesTobeCreated(SlideNumber))
catch ex as exception
If ex.message like PowerPointFailue then
PowerpointHasCrashed =True
End If
end try
SlideNumber +=1
end while
If PowerpointHasCrashed =true then
SlideNumber -=1
'Do some Stuff to repair the Damage and start the loop again.
End If