AnsweredAssumed Answered

'Object reference not set to an instance of an object.' GetVar C#

Question asked by Sean Donnelly on May 26, 2017
Latest reply on Jul 19, 2017 by Sean Donnelly

Basically, I have my own search using WinForms (standalone application outside of PDM) so that I can search for "base" part numbers in my search and pull in variables when I select the filename in the list. The first part works nicely and I'm trying to now pull variables from the file. I can get file information just fine, but it's breaking when I try to set my textboxes to the object string.

 

Edit: I should mention the checkVault() is a method for getting the vault and logging in. this is not an issue as I am able to pull information using this method such as filename, path, id, etc.

 

        public void checkVault()
        {
            vault2 = null;
            if (vault1 == null)
            {
                vault1 = new EdmVault5();
            }
            vault2 = (IEdmVault7)vault1;


            if (!vault1.IsLoggedIn)
            {
                //vault1.LoginAuto("FocalPoint Vault", this.Handle.ToInt32());
                vault1.LoginAuto("FocalPoint Vault", this.Handle.ToInt32());
            }
        }

 

        private void listResults_MouseClick(object sender, MouseEventArgs e)
        {
            string configName = "Layout1";
            object Desc1 = null;
            object Desc2 = null;
            object Rev = null;
            //object StockingType = null;


            int numSel = listResults.SelectedIndex;
            if (numSel >= 0)
            {
                checkVault();


                IEdmFolder5 retFolder = default(IEdmFolder5);
                aFile = vault1.GetFileFromPath(listResults.SelectedValue.ToString(), out retFolder);


                IEdmEnumeratorVariable10 myvars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object  
                myvars = (IEdmEnumeratorVariable10)aFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file  


                //myvars.GetVar("CreatedBy", configName, out CreatedBy); //Use the GetVar method  
                myvars.GetVar("CAD_Description", configName, out Desc1);
                myvars.GetVar("CAD_Description1", configName, out Desc2);
                myvars.GetVar("CAD_Revision", configName, out Rev);
                myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors  
                                         //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID
                //breaks here
                textRev.Text = Rev.ToString();
                textDesc1.Text = Desc1.ToString();
                textDesc2.Text = Desc2.ToString();
            }




        }

Outcomes