Add in error message

Hello,

I created a C# add-in in visual studio 2013, targeting .NET 4.0.  I installed it using the Administration Tool. 

It was only supposed to run when clicking on a button on a file card.  For some reason, it also seems to be

running when I am using the search cards, specifically when press the green run button on the toolbar,

or when I press the Enter key in one of the search textboxes. 

The error message is as follows:

Call to method 'OnCmd' in add-in 'ImportSolidWorksPartsAndAssemblies', written by company 'xyz' failed.

Error code = 0x0800401FD (Object is not connected to server).

First I don't understand the error message and how to eliminate it, second I don't understand why my

add-in seems to be getting called from the search form when I never told it to.

Any help would be appreciated.

thanks

Jeff

SolidworksSolidworks Pdm enterprise Pdm
Answers 4
TW
TW 2014-02-17 Best Answer

Hi Jeff.

Before getting too deep, into debugging I have a few questions:

As you've probably read in the API help, a card button Addin is notified when the button is pressed, when a card field is updated, and when the save or apply button is pressed depending on how you coded the Addin.

What description did you give the Addin in the GetAddinInfo?

What company name did you give it there also?

Is the namespace of your Addin ImportSolidworksPartsAndAssemblies?

SF
SF 2014-02-18

Hi Tim,

Here is my GetAddInInfo method

public void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 poVault, IEdmCmdMgr5 poCmdMgr)

        {

            try

            {

                //Specify information to display in the add-in's Properties dialog box

                poInfo.mbsAddInName = "ImportSolidWorksPartsAndAssemblies";

                poInfo.mbsCompany = "Prop Shaft Supply";

                poInfo.mbsDescription = "An add in that attempts to get the custom " +

                    "properties from the part and solid model for use in the data cards.";

                poInfo.mlAddInVersion = 1;

               

                //Specify the minimum required version of SolidWorks Enterprise PDM

                poInfo.mlRequiredVersionMajor = 6;

                poInfo.mlRequiredVersionMinor = 4;

                //notify the add-in when a file data card button is clicked.

                poCmdMgr.AddHook(EdmCmdType.EdmCmd_CardButton);

            }

            catch (COMException comEx)

            {

                Interaction.MsgBox(

                    string.Format("HRESULT = 0x{0}\n{1}",

                    comEx.ErrorCode.ToString("X"),

                    comEx.Message

                    ));

            }

            catch (Exception ex)

            {

                Interaction.MsgBox(ex.Message);

            }

        }

No, the namespace for this addin is:

PSS.EPDM.MigratonFileCard

I just called it ImportSolidworksPartsAndAssemblies in the Admin tool

thanks

Jeff

TW
TW 2014-02-18

Jeff,

Is your addin using an Excel table? See this KB article here The server may be a data server (excel) and disabling all Excel addins may fix your issue.

Also, can you post your validation code in the OnCmd method? I think I know what's going on...Are you testing the incoming poCmd struct to see if it is your specific button that has been pushed?

Tim

SF
SF 2014-02-18

Tim,

No on the Excel, but I think you got it, here was my OnCmd code:

               if (poCmd.meCmdType == EdmCmdType.EdmCmd_CardButton &&

                    poCmd.mbsComment != "OK")

                {     

                    ...

                }

I didn't realize the Add-In name was the value of the poCmd.mbsComment, I just noticed the value was "OK" when my search button was pressed. 

So I changed it to this:

                if (poCmd.meCmdType == EdmCmdType.EdmCmd_CardButton &&

                    poCmd.mbsComment == "ImportSolidWorksPartsAndAssemblies")

                {     

                    ...

                }

and the code inside does not run when my search cards run, which is what I wanted to happen

thanks for your help.

Jeff