c# - Handle access violations in COM interop -


my managed app using com interop. unfortunately there bug in com component causes access violation. when bug hit, whole app crashes, handler attached appdomain.currentdomain.unhandledexception didn't chance run. wonder if there way handle av, show friendly message user , recover managed app?

there no way "handle" access violation.

depending on component using , how implemented isolating inside second appdomain might still crash process - appdomains "only" .net-thing, native perspective of os not isolated.

if have problematic component can make usage of more robust using following approach:

create process (exe) wraps usage of component , exposes api (for example via ipc mechanism). can start exe separate process (from main exe) , use it... if need kill component after time and/or when condition met can kill "wrapper exe" main exe... depending on specific component might useful implement special "cleanup code" (possibly in separate thread) within "wrapper exe" gets executed when need kill "wrapper exe".

since implementing in .net can have "wrapper exe" "embedded resource" in main executable , start ram without writing filesystem.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -