Click here to Skip to main content
15,868,074 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The following is the piece of code i have tried to list down the projects for a domain in ALM and i am getting the following error message

Indexed property 'ITDConnection11.VisibleProjects' has non-optional arguments which must be provided


The error message is shown on this line of code
List proj = qctd.VisibleProjects;


I am struck now and not sure how to progress on this.. Could you please help me on this?

What I have tried:

using System;
using System.Windows.Forms;
using MetroFramework.Forms;
using MetroFramework;
using TDAPIOLELib;

namespace ALM___Utilities
{
    public partial class Form1 : MetroForm
    {
        public Form1()
        {
            InitializeComponent();

        }

        private void ALM_url_TextChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(ALM_url.Text) & string.IsNullOrEmpty(Username.Text) & string.IsNullOrEmpty(Password.Text))

                loginbutton.Enabled = true;
            else
                loginbutton.Enabled = false;

        }

        private void loginbutton_Click(object sender, EventArgs e)
        {
            string username = Username.Text;
            string password = Password.Text;
            string URL = ALM_url.Text;
            TDConnection qctd = new TDConnection();
            qctd.InitConnectionEx(URL);
            try
            {
                qctd.Login(username, password);
                if (qctd.Connected)
                {
                    MetroMessageBox.Show(this, "Logged in Successfully", "Login Status", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                List domainlist = qctd.VisibleDomains;
                List proj = qctd.VisibleProjects;
                foreach (string desc in domainlist)
                {
                    
                       
                   foreach ( var projname in proj)
                    { 
                        MetroMessageBox.Show(this, desc.ToString(), "domain", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //MetroMessageBox.Show(this, projname.ToString(), "domain", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    
                    {
                        
                    }
                        
                        //MetroMessageBox.Show(this, Project.ToString(), "prj", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                


            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, ex.Message, "Login Status", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }

        }
    }
}
Posted
Updated 21-Nov-18 14:25pm

You have to provide the Domain name - see the documentation VisibleProjects Property[^]
Instead of
C#
List proj = qctd.VisibleProjects;
foreach (string desc in domainlist)
{
try
foreach (string desc in domainlist)
{
    List proj = qctd.VisibleProjects(desc);
 
Share this answer
 
Comments
[no name] 21-Nov-18 17:06pm    
Non-invocable member 'ITDConnection11.VisibleProjects[string]' cannot be used like a method


I am getting the above message on the below line after editing as per above comment

 List projlist = qctd.VisibleProjects(desc); 
foreach (string desc in domainlist)
{
    List proj = qctd.VisibleProjects[desc];

}

The above code worked. The issue was , we have to use square brackets rather than paranthesis
 
Share this answer
 
Comments
CHill60 22-Nov-18 7:48am    
Actually, the original issue was that you were not passing any parameter at all!
[no name] 22-Nov-18 17:19pm    
I agree with you.. I will agree your answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900