Options

Strange Automation Behavior

FishermanFisherman Member Posts: 456
This is very, very strange.

We have a .Net assembly (dll) that we wrote to facilitate communication of Navision order information to an XML Web Service that our customer operates. From that dll, we raise several events so that we can inform Navision of the state of the transmission, and so that we can keep the .Net assembly as "black box" as possible.

Overall, this works well, but we've just noticed some very odd behavior when it comes to raising errors out of the C/AL triggers handling the .Net events. For some reason, calling "ERROR" in the trigger actually causes a CLR error to be raised inside of the sub that raised the event. It's almost like calling the C/AL ERROR statement is injecting the error back into .Net as an exception.

We know that this is happening because our exception handler in our .Net assembly logs the general exceptions to the system event log, and changing the ERROR to a MESSAGE causes the behavior to stop.

Has anyone else experienced this? This seems like an incorrect vector to me - I don't think that calling C/AL ERROR should inject a system.exception back into my running assembly space....

Comments

  • Options
    FishermanFisherman Member Posts: 456
    no takers? Kriki?
  • Options
    kinekine Member Posts: 12,562
    Are you using the DLL on NAS or on Client? (without or with GUI)
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    FishermanFisherman Member Posts: 456
    NAV 4.02 client.
  • Options
    krikikriki Member, Moderator Posts: 9,090
    Fisherman wrote:
    no takers? Kriki?
    Actually, .NET is not between my specialties. :oops:
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    FishermanFisherman Member Posts: 456
    I'm so disappointed. :)

    I thought you were a fellow nethead.

    I'm considering reporting this to MS as erroneous behavior - your thoughts?
  • Options
    Saint-SageSaint-Sage Member Posts: 92
    Though this sounds odd, it also sounds reasonable. When the C/AL Error is called, all memory in the scope of that form, view, or whatever are cleared, uncommited transactions rolled back etc...

    So Nav is probably trying to terminate the automation, or at least being nice and asking the automation to terminate itself when you throw an error.

    I am not certain of this but from my standpoint this makes sense.

    No one loves you like the one who created you...
  • Options
    FishermanFisherman Member Posts: 456
    I guess that's feasible, but I'd think that at that point C/AL is making an invalid attempt to dispose of the COM interface...

    I don't know - it seems odd to have the call to error inject an error into an external dll, especially when the .Net dll is catching exceptions - how does a system.exception map to a COM interface?

    Generally speaking, injecting calls into a dll that weren't explicitly exposed is considered a security issue and possible vector....
  • Options
    kinekine Member Posts: 12,562
    1) All the Automation you run from NAV are running in context of NAV client - it becomes part of NAV, not "external dll".
    2) You can try to define SingleInstance codeunit with this Automation and events to prevent automatic disposing when error...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    SavatageSavatage Member Posts: 7,142
    Fisherman wrote:
    I'm so disappointed. :)
    I thought you were a fellow nethead.
    I'm considering reporting this to MS as erroneous behavior - your thoughts?

    yes Codemaster Kriki not nowing .NET seems to erroneous behavior to me too. :mrgreen:

    :lol:
  • Options
    krikikriki Member, Moderator Posts: 9,090
    Savatage wrote:
    Fisherman wrote:
    I'm so disappointed. :)
    I thought you were a fellow nethead.
    I'm considering reporting this to MS as erroneous behavior - your thoughts?

    yes Codemaster Kriki not nowing .NET seems to erroneous behavior to me too. :mrgreen:

    :lol:
    Well, I have it on my to-learn list.
    I also have SQLServer programming on my list (with a higher priority), but I don't have the time for that either. :(
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    FishermanFisherman Member Posts: 456
    Well, Kriki - Those are my primary languages. I'm a .Net programmer and SQL DBA. They're not that hard to pick up if you have the right books - I can send you some ISBNs of some of my favorites, if you like.
  • Options
    FishermanFisherman Member Posts: 456
    kine wrote:
    1) All the Automation you run from NAV are running in context of NAV client - it becomes part of NAV, not "external dll".

    I'm unsure what you mean by this. NAV is not capable of instantiating the .Net framework, under which my Dll would have to run. The only thing it can do is call the appropriate class given the Class ID in the system registry, and pull the IDispatch information for COM interop with the assembly that is loaded under the .Net runtime. To say that "it becomes part of NAV" is not entirely correct - it becomes linked to NAV through IDispatch.

    This is why I think that it's an incorrect vector. IDispatch shouldn't be exposing any way for NAV to raise an error inside of my dll...
Sign In or Register to comment.