Page 1 of 1

Accessing Phidget objects leads to "Device not attached" error in a Multiform C# Application

Posted: Sun Mar 31, 2019 7:09 am
by faiz180490
Hi,

I have 1019_1 Phidget I/O board and I have written a C# program to interface with this board. My Application makes use of 2 Digital Outputs and 1 Digital Input. It is a multiform Application meaning I hide and move to new forms regularly. There is one main Form from which I move to many child forms. I have defined and attached my I/O in the main form and will be using it in a child form. However, As soon as my main form closes, the device gets detached and then attached again after some time. Sometimes it just remains detached and the detached method is not even called. This causes a "device not attached" error. So my question is - what is the right way to attach a device and keep it attached until I close or exit the application? Please do let me know if you need more information. Thanks in advance for the help.

Regards,
Faizan.

Re: Accessing Phidget objects leads to "Device not attached" error in a Multiform C# Application

Posted: Wed May 01, 2019 10:47 pm
by faiz180490
For any one having trouble with this problem, I managed to solve it by doing all the attaching in my main Program.cs. Just define them with Public scope and you can access the device objects in any subforms. Then you can detach them on Application Exit.

Probably this is basic C# coding but hope it helps someone.