c# - .NET Fetch all exception in 3rd party app -


we integrating 3rd party application supplying file can import. file contains many properties(+100) , not of them mandatory, need few. however, application keeps crashing(gently, alert due big try catch) 'object not set reference ...' without stacktrace. @ place 3rd party app not verifying optional parameters on nulls causing crash. searching property searching needle in haystack.

is possible somehow monitor exceptions of application don't have source of if caught? can stacktrace , check ilspy property causing problem.

the 3rd party app relatively big company. cannot communicate developers.

you try:

assembly otherassembly = typeof(/* class of other assembly */).assembly;  appdomain.currentdomain.firstchanceexception += (sender, fceea) => {     appdomain domain = (appdomain)sender;      var method = fceea.exception.targetsite;     var declaringtype = method.declaringtype;     var assembly = declaringtype.assembly;      if (assembly == otherassembly)     {         // log stacktrace of exception, or whatever          // want     } }; 

this let see exceptions (even catched). have put code program starts (or in other places ok, try not execute multiple times, because event appdomain-wide)

note considering how stack trace inside exception handled, perhaps it's better to:

if (assembly == otherassembly) {     // log stacktrace st of exception, or whatever      // want     string st = new stacktrace(1, true).tostring(); } 

so can see full stack trace.

now, i've suggested you, write small console app/winforms app, add reference other exe (yes, can add reference .exe if written in .net :-) ), , in main like:

var otherassembly = typeof(/* type other assembly */).assembly;  // classes in assembly static main() has // "right" signature var main = (from x in otherassembly.gettypes()             y in x.getmethods(bindingflags.static | bindingflags.public | bindingflags.nonpublic)             y.name == "main" && (y.returntype == typeof(int) || y.returntype == typeof(void)) && y.getgenericarguments().length == 0             let parameters = y.getparameters()             parameters.length == 0 || (parameters.length == 1 && parameters[0].parametertype == typeof(string[]))             select y).single();  if (main.getparameters().length == 0) {     // static main()     main.invoke(null, null); } else {     // static main(string[] args)      // note new string[0] string[] args!     // can pass *your* string[] args :-)     // or build 1 want     main.invoke(null, new object[] { new string[0] }); } 

to invoke other main(). before doing this, have setup firstchanceexception handler


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -