Greetings. I have been looking answer for this problem last 6 months but so far I have been unable to find solution.
I have a program which I have translated from VB 6.0 -> VB.net and it works perfectly on my computer (where I did all the re-programming). However, on the any other computer I install my program and execute one particular piece of code, it crashes and throws following error:
System.StackOverflowException
OK. I installed VB.net and all the necessary stuff on a computer which does this error and started to debug my code. I found out that it crashes at the following code, when it gets in the line With gWordApp.Selection.Find. Few times program has crashed in the line gWordApp.Selection.WholeStory() too. So this has something to do with the word application.
Code:
Public gWordApp As Word.Application
Sub Ole_Word_Replace(ByRef sTeksti1 As String, ByRef sTeksti2 As String)
On Error GoTo Ole_Word_ReplaceVirhe
gWordApp.Visible = True
gWordApp.Selection.WholeStory() ' It crash here
With gWordApp.Selection.Find ' Or it crash here
.ClearFormatting()
.Text = sTeksti1
.Replacement.Text = sTeksti2
.Forward = True
.Wrap = Word.WdFindWrap.wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
gWordApp.Selection.Find.Execute(Replace:=Word.WdReplace.wdReplaceAll)
After the crash, I look at the debug window and see following error in there:
Fatal execution engine error.
Fatal execution engine error.
The program '[2416] Maso.exe' has exited with code 0 (0x0).
Note, that this piece of code goes well with my own computer I made the code at the first place (so I presume the code itself is not faulty). But that is the only computer this piece of code works. Also the program itself works perfectly except this one thing. My own computer is Windows 2000 and other computers are either Windows 2000 or Windows XP (I have installed this program in many computers). Of course all the computers has framework and MDAC 2.7 and service pacs for those too.
Any advice appreciated.
I have a program which I have translated from VB 6.0 -> VB.net and it works perfectly on my computer (where I did all the re-programming). However, on the any other computer I install my program and execute one particular piece of code, it crashes and throws following error:
System.StackOverflowException
OK. I installed VB.net and all the necessary stuff on a computer which does this error and started to debug my code. I found out that it crashes at the following code, when it gets in the line With gWordApp.Selection.Find. Few times program has crashed in the line gWordApp.Selection.WholeStory() too. So this has something to do with the word application.
Code:
Public gWordApp As Word.Application
Sub Ole_Word_Replace(ByRef sTeksti1 As String, ByRef sTeksti2 As String)
On Error GoTo Ole_Word_ReplaceVirhe
gWordApp.Visible = True
gWordApp.Selection.WholeStory() ' It crash here
With gWordApp.Selection.Find ' Or it crash here
.ClearFormatting()
.Text = sTeksti1
.Replacement.Text = sTeksti2
.Forward = True
.Wrap = Word.WdFindWrap.wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
gWordApp.Selection.Find.Execute(Replace:=Word.WdReplace.wdReplaceAll)
After the crash, I look at the debug window and see following error in there:
Fatal execution engine error.
Fatal execution engine error.
The program '[2416] Maso.exe' has exited with code 0 (0x0).
Note, that this piece of code goes well with my own computer I made the code at the first place (so I presume the code itself is not faulty). But that is the only computer this piece of code works. Also the program itself works perfectly except this one thing. My own computer is Windows 2000 and other computers are either Windows 2000 or Windows XP (I have installed this program in many computers). Of course all the computers has framework and MDAC 2.7 and service pacs for those too.
Any advice appreciated.