You'll need to post more information. You have an unhandled exception somewhere but see we don't know anything about your code then there is no way to provide useful guidance. Post some information like where the exception is occurring, what it was, anything that you were doing around that time frame, etc. Ideally you should be able to replicate the problem on the server under the debugger and be able to figure it out. Otherwise you'll need to add some logging or something. Your goal is to narrow down the problem to a call stack that you can then use to identify the function causing the problem. This should give you a better idea what is going on.
yes, what i found is because when we set openport = false, but internally hardware haven't change the status to false, and this will take time to change, so i put Sleep() to let it got time to refresh before i set openport = true, and this work.