Cancel
Showing results for 
Search instead for 
Did you mean: 

DFT - before save event runs more than once

Valued Contributor
Valued Contributor

Hi guys,

 

SE 2019, draft mode.

 

I'm opening first document, click on "Save" button - the BeforeDocumentSave event runs once. I'm closing document, opening another one - The BeforeDocumentSave event runs twice... For third one - three times etc....

 

Bug or what's going on?

2 REPLIES 2

Re: DFT - before save event runs more than once

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

Hi @p_jedrkowiak,

I don't think this is a problem of Solid Edge. I assume your  program registers the event again after it fires.

So this builds a loop and every time the handler routine is called one more time.

regards

JB
SE 2019, VS2017

Re: DFT - before save event runs more than once

Valued Contributor
Valued Contributor

Update:

 

I'm using a workaround solution, based on ribbon button. 

Resolved.

 

===========================================

Can't find a reason. 

Events are being connected in the standadrd way:

 

        private SolidEdgeFramework.Application _application;
        private IConnectionPoint _connectionPoint;
        private int _cookie;

        public MyEdgeBarControl()
        {
            InitializeComponent();
        }

        private void MyEdgeBarControl_Load(object sender, EventArgs e)
        {
            // Trick to use the default system font.
            this.Font = SystemFonts.MessageBoxFont;
            _application = (SolidEdgeFramework.Application)Marshal.GetActiveObject("SolidEdge.Application");
            ConnectEvents();
        }

        private void ConnectEvents()
        {
            // Get the event GUID.
            var typeGuid = typeof(SolidEdgeFramework.ISEApplicationEvents).GUID;

            // Get a reference to the IConnectionPointContainer.
            IConnectionPointContainer container = (IConnectionPointContainer)_application;

            // Lookup the IConnectionPoint.
            container.FindConnectionPoint(ref typeGuid, out _connectionPoint);

            // Advise the sink.
            _connectionPoint.Advise(this, out _cookie);
        }