web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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

I have the same question (0)
  • HGS Profile Picture
    309 on at

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans