Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Rejected .net-events in NAV 2013

(0) ShareShare
ReportReport
Posted on by 309

I need to receive events from a 32-bit COM-dll into NAV 2013. I am aware that NAV 2013 does not support that. However, it might be solved using Inter Process Communication, like Pipes or tcp. I have made it work when using a 64-bit windows form test application instead of NAV. When testing from NAV, the events raised in my 64-bit dll simply does not reach NAV. However, I can make it work using a syncronous solution, but I need an asyncronous solution, hence using threads. It seems like NAV rejects events from a threaded .net-dll. Could that be the reason? I do welcome explanations and alternative solutions.

*This post is locked for comments

  • HGS Profile Picture
    309 on at
    RE: Rejected .net-events in NAV 2013

    I have narrowed the scenarion to the fact that asynchronous events dont work for me despite following the rekkomendations in msdn.microsoft.com/.../hh169424(v=nav.71).aspx and msdn.microsoft.com/.../hh166110(v=nav.71).aspx.

    Here is the test code:

    CU:

    OBJECT Codeunit 99992 EventTestWithTimer

    {

     OBJECT-PROPERTIES

     {

       Date=13-10-29;

       Time=10:40:45;

       Modified=Yes;

       Version List=;

     }

     PROPERTIES

     {

       SingleInstance=Yes;

       OnRun=BEGIN

               EventTestWithNoTimer := EventTestWithNoTimer.EventsNoArgs();

               EventTestWithTimer := EventTestWithTimer.EventsNoArgsWithTimer();

               EventTestWithNoTimer.FireEvent();

             END;

     }

     CODE

     {

       VAR

         EventTestWithNoTimer@1000000000 : DotNet "'EventTestWithTimer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.MyEvent.EventsNoArgs" WITHEVENTS;

         EventTestWithTimer@1000000001 : DotNet "'EventTestWithTimer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.MyEvent.EventsNoArgsWithTimer" WITHEVENTS;

       EVENT EventTestWithNoTimer@1000000000::ChangedEvent@8();

       BEGIN

         MESSAGE('Direct Event.');

       END;

       EVENT EventTestWithTimer@1000000001::ChangedEvent2@8();

       BEGIN

         MESSAGE('Timer Event.');

       END;

       BEGIN

       END.

     }

    }

    DLL:

    using System.Timers;

    using System;

    using System.IO;

    namespace MyEvent

    {

       public class EventsNoArgs

       {

           public delegate void ChangedEventHandler();

           public event ChangedEventHandler ChangedEvent;

           // Invoke the ChangedEvent

           protected virtual void OnChangedEvent()

           {

               if (ChangedEvent != null)

               {

                   ChangedEvent();

               }

           }

           // The following method is exposed to C/AL and will invoke the event trigger that is registered in the ChangedEvent variable.

           public void FireEvent()

           {

               OnChangedEvent();

           }

       }

       public class EventsNoArgsWithTimer

       {

           public EventsNoArgsWithTimer()

           {

               System.Timers.Timer aTimer = new System.Timers.Timer(3000);

               aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

               aTimer.Enabled = true;

           }

           public delegate void ChangedEventHandler();

           public event ChangedEventHandler ChangedEvent2;

           // Invoke the ChangedEvent

           protected virtual void OnChangedEvent()

           {

               if (ChangedEvent2 != null)

               {

                   ChangedEvent2();

               }

           }

            private void OnTimedEvent(object source, ElapsedEventArgs e)

           {

               OnChangedEvent();

           }

       }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics NAV (Archived)

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2

#1
mmv Profile Picture

mmv 2

#1
Amol Salvi Profile Picture

Amol Salvi 2

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans