1

I am facing a very weird problem after releasing a application which is developed in c#.NET version 4.0 (client profile)

Actually, application open a word file using office interop. File gets open and as I started typing (modifying header text) in file app gets crashed. I spend 2-3 days to find reason behind app crash.

Here is what I collected from event viewer:

Source: .NET Runtime

Application: OES-PracticalClient.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
Stack:
   at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG ByRef, System.Runtime.InteropServices.HandleRef, Int32, Int32, Int32)
   at System.Windows.Forms.Application+ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr, Int32, Int32)
   at System.Windows.Forms.Application+ThreadContext.RunMessageLoopInner(Int32, System.Windows.Forms.ApplicationContext)
   at System.Windows.Forms.Application+ThreadContext.RunMessageLoop(Int32, System.Windows.Forms.ApplicationContext)
   at System.Windows.Forms.Application.Run(System.Windows.Forms.Form)
   at Secure_Browser_CS_Version.Program.Main()

Source : Application Error

Faulting application name: OES-PracticalClient.exe, version: 1.0.0.4, time stamp: 0x5725e4d6
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x000d0000
Faulting process id: 0xe44
Faulting application start time: 0x01d1b1cc5b6d0f8d
Faulting application path: C:\Program Files\myorg\product name\OES-PracticalClient.exe
Faulting module path: unknown
Report Id: 029300ed-1dc0-11e6-a33d-080027beb5a6

Report.wer file is uploaded here.

By event log it's clear that it's something related to access violation with interop (clear me if I am wrong) due to stack trace at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG ByRef, System.Runtime.InteropServices.HandleRef, Int32, Int32, Int32), but I am not able to identify what causing crash. Specially after I started typing.

Moreover on development,testing machine and client machine is having same OS and office version, but app crash is not happened on development and testing enviroment.

Here are the details of OS and software.

OS version

Windows 7 Enterprise Service pack 1 (32 bit)

Office version :

Microsoft Word 2013 (15.0.4701.1001) MSO (15.0.4701.1000) 32 Bit Part of Microsoft Office Professional Plus 2013

OldProgrammer
  • 12,050
  • 4
  • 24
  • 45
Amogh
  • 4,453
  • 11
  • 45
  • 106
  • For reference, [this SO](http://stackoverflow.com/questions/5006520/debugging-winform-crash-c-sharp-adplus-windbg) question has answer which points out that the access violation they encountered was caused by a garbage collected delegate. I thought I'd mention this, in case it's of any use. – Jason Evans May 19 '16 at 14:22

2 Answers2

0

I hope this will help, but we had a similar problem with using the Excel COM libraries from one of our applications that was almost the same. We would open the Excel document and start typing into a cell, and a COM exception would be thrown. It was intermittent, until we noticed a pattern.

We narrowed it down to the fact that we were trying to load data into the cells from code, and that was still running while attempting to type into the cell. Basically, it is a race condition where whatever the COM api is doing is not complete and it conflicts with a user typing.

I imagine Word and the other Office applications have the same kind of problems. We have not fixed this yet, but we are going to look for a method of identifying if a cell is currently being edited, or prevent the user from making modifications until our code has completed loading data into cells.

David Anderson
  • 13,558
  • 5
  • 50
  • 76
  • Thanks for your reply, but if we consider race condition like u explained but I didn't understand why application is working fine on some machines and not on others. – Amogh May 19 '16 at 14:48
  • While digging the cause we observed that exception is causing only on 32 bit of OS. On 64 bit all is working fine. – Amogh May 20 '16 at 05:17
0

Access violation exception mostly occurs if there is a Race Condition in your Code,Without seeing your code we don't know if there is any such problem.

If you are sure that your code doesn't have such conditions repairing the office installation will most likely solve the issue.

krish
  • 881
  • 7
  • 11
  • But why application is working fine on some machines and not on other. If we consider some race condition is happening then it shuld be on all machines (right?) – Amogh May 19 '16 at 14:50
  • Yes the problem could be on machine too that's why I suggested repairing your office installation in the server – krish May 19 '16 at 15:45
  • Nothing happened..same problem even after reinstallation. Even tried on formatted machine. – Amogh May 19 '16 at 16:33
  • One final suggestion check whether you have access permission to edit the particular word file by opening and editing the file in the location manually – krish May 19 '16 at 17:04