Invalid Program Exception was Handled
I am getting this error and Common Language Run time detected an invalid program when i debug my application using F5. If i use CNTRL+F5 it is working fine why it is happening can an开发者_Go百科y one tell.
Actually this one is coming only if i add DeployLX licensing which is a licensing software from XHEO.
The behavior you are experiencing is undoubtedly a consequence of your application being run with the debugger attached. When you start your application using Ctrl+F5, you are telling Visual Studio to "Start Without Debugging", as compared to just pressing F5, which tells Visual Studio to "Start Debugging". The difference between the two commands is simply that the former does not attach the debugger to your code's process. Note that this is not the same as the difference between a Debug build and a Release build! Either build type can be run with or without the debugger attached.
Running your application without the debugger attached means a couple of different things:
- Breakpoints will not be hit
- Debugging symbols (your .PDB files) are not loaded, so you cannot step through the code
- Statements involving the
System.Diagnostics.Debug
class will not be executed - In C++, variables will not be initialized to their default values (but rather left as uninitialized)
In your case, I would guess that the exception you're seeing is being caught and handled somewhere higher up the stack from where it is thrown (presumably by some of the code provided by the DeployLX licensing stuff, although I don't know anything about this and have never used it) and therefore not shown unless you have the debugger attached. With the debugger attached, the exception is logged and displayed for informational purposes, regardless of whether or not it is handled appropriately.
You didn't explain exactly where this error is being displayed and how you are "getting" it. But if you'd like to customize the way exceptions are handled when the debugger is attached to the process running your code, open the "Debug" menu and click on the "Exceptions" option. From there, you can choose to break on all exceptions, even those that are handled, if you'd like to see what code is throwing the exception.
According to this question, Clean Solution might be a good bet.
精彩评论