External component randomly throwing an exception

So I've been working on a certain project for quite some time, and it's starting to get really annoying because I can't get it to work for more than one day at a time. Every day when I come into work in the morning, there's a new error. This particular error has come up before and I haven't been able to figure out how to fix it and I've had to start from scratch a few times to get rid of it. I start over, the program works fine for the rest of the day, and then the next day I come in and get the same error. My program is a user interface for a camera that my company makes, and when you run the program, it first shows a box that has the connection status of the various parts of the user interface. There's three different things it has to connect to, with the camera being the last thing. Yesterday, and many other days, it has gone through each of these connections perfectly fine and with no errors or exceptions. This morning, however, after I connected to the first two object, the camera threw an exception. The specific error message was "Exception Occurred: External component has thrown an exception". I haven't made any changes to the source code since yesterday, I checked all my path's and directories and they seem right, and I'm really just completely lost as to why this ALWAYS happens the day after I actually get it working. I'm using VS2010 Professional C++ and the camera that I'm using is a JAI BM-141GE network camera. It works fine in the JAI Control Tool, it shows the video feed. It just throws an exception whenever my program tries to connect to it, even though I haven't changed anything since yesterday and yesterday it worked fine. If anyone has any idea what's happening, why it's happening, or how to fix it, I would be extremely grateful. Thank you very much.
You're dealing with hardware and all sorts of things can happen. Is the camera actually connected? Is it turned on? What if it shuts off? What if it's battery runs out? What if the cable gets unplugged? What is the cable has an intermittent connection and it seems like the camera connects and disconnects 5 times per second?

What happens if the camera goes to sleep at 2am? Or if your computer does an update and shuts down / restarts the USB driver in the middle of the night? It sounds like you might be facing this sort of thing.

The best thing you can do is try to get as much diagnostic info as you can when the exception is thrown. But the bottom line is that your code needs to be prepared for a flaky camera, even a hostile one (e.g., a hacker replaces the camera and attempts to use your program as a vehicle for an attack).
Well I'm working on code that I had no part in writing originally, and it's a very large and very complex(for my level as a sophomore-going-into-junior engineering major) project. I'm just modifying it to do some basic image processing, so I'm rather apprehensive about touching the code that's doing the connections to the camera and stuff, especially because it's a network camera and I find that's rather trickier than a USB webcam. I think your point about the computer shutting down and restarting the driver might be what's going on, I always shut it down when I leave work. It's just annoying that this is the FOURTH time that I've had it working fine one day, and the next day I come in, start it up without changing a single thing, and get this error that I can't fix and have to start from scratch. Obviously I save the changes I've made and it only takes about half an hour to delete the broken program and copy over the original working one and get it up and working to the point I had it before, but it's just annoying to have to do that every day. Do you have any suggestions as to how I could find out if the driver restart is actually what's going on? Thank you so much for your answer.
Topic archived. No new replies allowed.