-1

When I start debugging Excel add in from visual studio, get the following errors

A first chance exception of type 'System.NullReferenceException' occurred in PRS.NET.Core.exe

A first chance exception of type 'System.InvalidOperationException' occurred in PRS.NET.Core.exe

How can I fix this?

user3289230
  • 431
  • 2
  • 6
  • 19

1 Answers1

0

Are those merely errors in your output window, or are you having the exception thrown at you?

If it is just in the output window you can safely ignore this. Whenever an exception is thrown a message will appear in the output window, even if the calling code handled the exception. Depending on the project this is quite a common technique to deal with parameter validation. Something along the lines of - let's try it and if it fails (Exception is thrown) we go to our default way of dealing with the situation.

So, in summary, having an exception reported is only of concern to you, if it has not been handled.

Jens Meinecke
  • 2,904
  • 17
  • 20
  • it shows only on output window and does not interrupt process at all. But when I publish and deploy to other machine, it is problem. Every time close Excel, the com add in disappears because exception is thrown. If I handle this as unhandlled exception, it does not let me treat as unhandlled exception. – user3289230 Jan 19 '16 at 03:30
  • Are you sure that the error messages that you are seeing in the debugger are the root cause of the errors that are causing the program to crash in the production environment. My bet is that you are looking at two different problems here - one is the handled exceptions. And one is some problem to do with Excel not working the same way in the production environment as it is on the debugging environment. Excel is notorious for not being consistent between versions for example so something that works with your version of Excel might fail on the production version of Excel – Jens Meinecke Jan 20 '16 at 05:31