Link to home
Start Free TrialLog in
Avatar of leonstryker
leonstrykerFlag for United States of America

asked on

Debugging a DLL

I have a DLL which is referencing another DLL. Inside my DLL there is a function:

        public string[,] querycols1010(int queryID)
        {
            string[][] tempval;

            tempval =  comLink.querycols1010(queryID);

            string[,] colInfo = new string[6, tempval.GetUpperBound(0)];

            for (int k = 0; k <= 5; k++)
            {
                for (int i = 0; i <= tempval.GetUpperBound(0); i++)
                {
                    colInfo[k,i] = tempval[k][i];
                }
            }
            return colInfo;
        }

Open in new window


When I try to use this function from VBA I get an error "Index was outside the bounds of the array". I would like to debug my C# dll code to see what is going on as I have a feeling that there is something wrong with my array conversion, but not sure how to setup the debugging. Help would be appreciated.

Leon
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of leonstryker

ASKER

This function is in a DLL, I am not sure how to check it.
tempval =  comLink.querycols1010(queryID);
if(tempval.GetUpperBound(0) < 0)
{
  //Something is wrong ?  Put your code here to cope with that case
}
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I figured it out. I reversed the elements of the arrays. The correct version of the code is

            string[,] colInfo = new string[tempval.GetUpperBound(0), 6];

            for (int k = 0; k <= tempval.GetUpperBound(0) - 1; k++)
            {
                for (int i = 0; i <= 5; i++)

Open in new window


Thanks for your help