c# - How to unload unsued COM objects/libraries after a complete restart? -


here thing. i'm connecting via com devices @ knx/eib. - , want ready worst-case anyways - application crashes leaving objects , libraries exposed somewhere, somehow. noticed when restart app have trouble connection again. error connection procedure working normally. connect procedure working not, randomly. bad! after time (several minutes) seems work again after series of complete fails. think see pattern now. doesn't work after crash no clean disconnect. guess there objects hold connection device why can't new connection. why ask question.


question:

  • how unload unused objects kill undead connections?
  • how make windows check unused libraries unloaded?

i want tell windows, "i messed badly , need continue work. please clean mess me, can start fresh! deserve 2nd chance?"

edit:
scenario app has crashed , closed. have no references anymore. no clause or anything. app can started again. can clean mess has been made before, programmatically?

edit 2:
hans gave me hint of killing responsible server. solve calling taskkill on startup (at least long i'm in dev). , works!

c:\windows\system32\taskkill.exe /f /im falcon.exe 

this failure mode of out-of-process com server. if client program crashes desktop without releasing interface pointers server unaware client isn't around anymore. , tends balky when try reconnect, many servers permit 1 client.

by far common way programmers induce failure mode using debugger. they'll click red button or use stop debugging command. bam, no cleanup of course.

com garbage-collects unused servers automatically. isn't particularly fast, takes easy 10 minutes before decides needs step in. , doesn't work every server, office programs notoriously don't cleaned-up example.

not can when app keels on in regular usage. otherwise kind of problem killed middle-ware. still, having such mishap in c# program pretty unusual, clr releases interface pointers @ program termination when app crashed exception. you'd have have nasty kind of mishaps bypass this, critical exceptions executionengineexception or 1 site named after.

don't focus on stop debugging induced failures, normal , using task manager kill server expected , required. otherwise sure nasty bugs out of code , won't have problem. if need more sure contact owner of server, sure have small repro project available demonstrates issue.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -