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

Supporting Visual Studio on Windows
Post Reply
faiz180490
Fresh meat
Posts: 2
Joined: Sun Mar 31, 2019 6:59 am
Contact:

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

Post 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.
faiz180490
Fresh meat
Posts: 2
Joined: Sun Mar 31, 2019 6:59 am
Contact:

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

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests