Reply

SEAddin cann't install!

[ Edited ]

 

Hi All,

 

Sorry if this is not the correct place for this. 

My seaddin program(use C#) install other computer, when I select the menubutton "add-in--myaddin", I get a dialog box that says:

 

object reference not set to an instance of an object

Can anyone tell me why? This progam is right at development computer.

Any help would be greatly appreciaited.

 

Thanks

Fatkids.

 

 

Posted by: fat kids
Post date: 9/7/2009 5:49:34 AM

3 REPLIES

RE: SEAddin cann't install!

[ Edited ]

What menu button are you selecting? If you are selecting a button in Solid Edge, then your add-in is up and running. The message sounds like it comes from .NET. Lots of things could be going wrong. Did you deliver the interop assemblies that were created when you imported references to the Edge type libs along with your add-in assembly?

 

That message usually occurs when your .NET code references an object that has not been instantiated. So for instance you might be trying to get the active document when no document is open. If you fail to check the object you assigned the active document to in order to make sure it is not null before accessing some property or calling some method, .NET might toss up that message box.

 

Posted by: R.D. Holland
Post date: 9/10/2009 9:07:25 AM

RE: SEAddin cann't install!

[ Edited ]

 

Hi,holland!

I use the SEAddin template of C# 2005.

 

In my program, when I execute to "addin.SetAddInInfo", my program jump to "catch (System.Exception e)". The "e.Messag" is "Object reference not set to an instance of an object.". Why???

 

public void OnConnectToEnvironment(string EnvCatID, object pEnvironmentDispatch, bool bFirstTime)

{

try

{

// Allocate room for required arrays for CommandBars.

Array commandNames = Array.CreateInstance(typeof(String), 3);

Array commandIDs = Array.CreateInstance(typeof(int), 3);

 

// Populate arrays.

commandNames.SetValue("cmdAbout\n\nAbout SEAddin3\nAbout Inter addin", 0);

commandNames.SetValue("cmdOpenFile\n\nOpen File\nOpen File", 1);

commandNames.SetValue("cmdIntegrated to Create\n\nIntegrated to Create\nCreat", 2);

commandIDs.SetValue(101, 0);

commandIDs.SetValue(102, 1);

commandIDs.SetValue(103, 2);

 

// Call SetAddInInfo. The problem is here!!!

 

addin.SetAddInInfo(

Marshal.GetHINSTANCE(this.GetType().Module).ToInt32(),

EnvCatID,

"SEAddin3",

1,

2,

1,

2,

commandIDs.Length,

ref commandNames,

ref commandIDs);

//MessageBox.Show(Marshal.GetHINSTANCE(this.GetType().Module).ToInt32().ToString());

// Check for 1st time.

if (bFirstTime)

{

SolidEdgeFramework.Environment environment = (SolidEdgeFramework.Environment)pEnvironmentDispatch;

environment.CommandBars.Add("Inter addin", SolidEdgeConstants.SeBarPosition.seBarTop, false, false);

addin.AddCommandBarButton(EnvCatID, "SEAddin3", 101);

addin.AddCommandBarButton(EnvCatID, "SEAddin3", 102);

addin.AddCommandBarButton(EnvCatID, "SEAddin3", 103);

}

}

catch (System.Exception e)

{

MessageBox.Show(e.Message);

}

 

Posted by: fat kids
Post date: 9/10/2009 8:00:35 PM

RE: SEAddin cann't install!

[ Edited ]

I don't see anything obvious in the code. But I didn't expect to since you stated it works on your dev machine. I see the commented call to Messagebox.Show after the call to set the add-in info. Are you obtaining the marshaler? And what is the value of "addin" in the addin.SetAddInInfo? I suspect the "addin" variable is not set to an object. Where do you set it and what is its value at the time of the call?

 

Posted by: R.D. Holland
Post date: 9/14/2009 9:06:38 AM