RaiseControlAddInEvent throws NullReferenceException

wakestarwakestar Member Posts: 207
edited 2011-09-23 in NAV Three Tier
Hi all

I have a page (runmodal = false) with a timer AddIn (freddy's) on it.
The timer triggers every second:
OnControlAddIn(Index : Integer;Data : BigText)

Everything works fine, except when I change the company or the language of the RTC.

RTC then restarts the Pages but the timer event gets raised:
this.RaiseControlAddInEvent((int)TimerFunctions.Counter, this.count++.ToString());

this causes a Null Reference Exception and the RTC throws this error:

Microsoft Dynamics NAV

Page is not open.
OK

Which is true... but how can I avoid this situation?

Comments

  • deV.chdeV.ch Member Posts: 543
    Can you post the whole code of freddys timer? I had other strange behaviour like that with my addin, the problem was that i hadn't overriden the dispose method and distroyed my objects correctly!

    maybe you need to do this too

    EDIT: I took a look at his code (freddys) and found that he implements dispose ... :-k

    EDIT2: What is TimerFunctions? I don't find this one in freddys code (here: http://blogs.msdn.com/b/freddyk/archive/2009/11/03/timer-events-on-a-page.aspx)
  • wakestarwakestar Member Posts: 207
    TimerFunctions = enum .. just an Index...
    Counter = 1

    basically the same like:
    this.RaiseControlAddInEvent(1, this.count++.ToString());
  • wakestarwakestar Member Posts: 207
    btw. I had to remove the

    ...
    Application.EnterThreadModal
    Application.LeaveThreadModal
    ..stuff because I need the events ALWAYS fired.

    Freddy's example doesn't fire events when you have a modal form open
Sign In or Register to comment.