AnsweredAssumed Answered

While using PIServerPicklist, code throwing an exception "Unable to cast object of type 'System.__ComObject' to type 'PISDK.PISDKClass'"

Question asked by pvchaudhari on Nov 7, 2017
Latest reply on Nov 12, 2017 by pvchaudhari

Hi,

I want to use piServerPickList control in my code.

However, while doing so the code throws an exception : Unable to cast object of type 'System.__ComObject' to type 'PISDK.PISDKClass' in project designer.

            this.piServerPickList1.BackColor = System.Drawing.SystemColors.Control;

            this.piServerPickList1.Location = new System.Drawing.Point(160, 91);

            this.piServerPickList1.Name = "piServerPickList1";

            this.piServerPickList1.ReadOnly = true;

            this.piServerPickList1.SelectedServerNames = new string[0]; => this is the line where code is throwing an exception.

I am handling the click event as per below, but still it is not working.

private void piServerPickList1_Click(object sender, EventArgs e)

        {

            string srv = piServerPickList1.SelectedServers.ToString();

        }

could anyone please help me on this exception?

 

Thank you,

Prasad Chaudhari.

Outcomes