Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

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

(0) ShareShare
ReportReport
Posted on by 993 Super User 2024 Season 1

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 ?

*This post is locked for comments

  • Inge M. Bruvik Profile Picture
    Inge M. Bruvik 993 Super User 2024 Season 1 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 993 Super User 2024 Season 1 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,162 Most Valuable Professional 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?

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans