Skip to main content

Notifications

Microsoft Dynamics NAV forum
Suggested answer

Using a DOTNET variable working ok client side but is giving me an error when i run it server side

Posted on by 32,744 Moderator

I have written a .net assembly compiled as an DLL that i want to use in Dynamics NAV 2017.  My DLL has events so i want to run it in a codeunit and have the "Run on client" property to false so i can have the "WithEvents" property set to false.

I have copied the DLL file to the Add-ins folder both for the service and for the client.

In my codeunit i call the constructor as this:

myDll: = myDll.Constructior;

myDll.myMethode();

When i run the codeunit i get an error saying:"Object reference not set to an instance of an object".

But when i change the "Run on client" property to yes and set the "WithEvents" to false - the codeunit is executing with out error. 

Normally i am used to getting this error when the DLL is not present in the Add-ins folder for the service but this is not the case in this situation.

Can anyone help me explaine why the codeunit cause an runtime error when i run it server side and not when i run it client side and how i should fix this ?

  • Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: Using a DOTNET variable working ok client side but is giving me an error when i run it server side

    I tried the same thing on another installation running the same build of Microsoft Dynamics NAV 2017. And there i am able to run my code without error even when the DOTNET variable is set to run on server. So i guess the problem must be caused by some condition on the machine i am doing my development on. But have still not be able to figure out what it is.

  • Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: Using a DOTNET variable working ok client side but is giving me an error when i run it server side

    There are dependencies to another assembly but that assembly is also present in the server tier add-ins folder.

    I could ofcourse be tricked if there is an assembly in another sub folder to the add-ins folder on the client side that is used when running client side.  I will try it on a fresh installation to see if i get the same problem there.

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,160 on at
    RE: Using a DOTNET variable working ok client side but is giving me an error when i run it server side

    Yes, you're right. If RunOnClient = No the DLL is executed at server side and must be present in add-in folder of the service tier.

    If client and server has the same DLL deployed in the same way, it's strange that RunOnClient = yes works and RunOnClient = false does not. Maybe you have dependencies from other assembly?

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 9th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,246 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,041 Super User 2024 Season 2

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans