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
C#

Avatar of undefined
Last Comment
leonstryker

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
AndyAinscow

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
leonstryker

This function is in a DLL, I am not sure how to check it.
AndyAinscow

tempval =  comLink.querycols1010(queryID);
if(tempval.GetUpperBound(0) < 0)
{
  //Something is wrong ?  Put your code here to cope with that case
}
SOLUTION
kaufmed

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
leonstryker

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
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck