Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Cannot create an instance of the following .Net framework - Custom DLL - NAV2017

Posted on by Microsoft Employee
Hello Nav community

I got the following problem:
For a interface to an document management system we need some custom .NET DLL's. But for all theese Dll's I get an runtime error:
NAVDllError.PNG
In NAV2009R2 we used the same interface and used the DLL's via Automation/Com Interface which worked fine. In NAV2017 we would like to use the dot net classes directly.
I Copied the folders with the requierd DLL's to C:\Program Files\Microsoft Dynamics NAV\100\Service\Add-ins on the dynamics nav Service Tier.
In the development enviroment I created a DotNet variable and then I selected my DLL from the Server Tab in the assemlbies. This worked fine and I can also see all the methods and properties of the classes in both the client and the server, so the DLL is found.

But when I execute the code I always get this error:

This error message I got for both Dll's I tried, one is a PDF Creator DLL for .net from 
https://www.pdf-tools.com/pdf20/de/home/ and the other is from the document management system.
The error I got with RunOnClient=Yes and also for RunOnClient=No
When debugging the error already pops up at the line where I try to initialize the variable in C/AL: NewPDFAPIL := NewPDFAPIL.Secure; So it is not a error in a function, already in the initzializing.

I already tried following things and could not solve the problem:
  • I installed the DLL directly on the Client in the Addin Folder
  • I cleared the temporary cache on both the client and the server with the microsoft dynamics nav addin folder.
  • I gave full control rights to users on the folder that contains the dll
  • I tried different versions of the product/dll

I am thankful for any help or suggestions

Best Regards
Joshua
 

*This post is locked for comments

  • kub4nek Profile Picture
    kub4nek 10 on at
    RE: Cannot create an instance of the following .Net framework - Custom DLL - NAV2017

    Hi,

    I've been facing the same issue since NAV 2018 (now in BC14) but only in some environments (which is Citrix based; if that matters).

    But anyways: a workaround would be to copy the DLL into Service parent folder of the Add-Ins folder.

    HTH,

    JC

  • Travis Ashby Profile Picture
    Travis Ashby 5 on at
    RE: Cannot create an instance of the following .Net framework - Custom DLL - NAV2017

    Hello,

    I encountered this error this morning,

    It ended up being that the Microsoft.Dynamics.Nav.Server.exe.config file was no longer a CONFIG file rather just a text file on the server.

    I replaced the text file with a working CONFIG file and cleared my local NAV cache by going to

    %TEMP%\Microsoft Dynamics NAV\Add-Ins and deleting the folder.

    re opened NAV and I was able to use all Ad-Hoc reports on the connection.

    Hope this helps someone in the future.

  • Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: Cannot create an instance of the following .Net framework - Custom DLL - NAV2017

    Have you tired to registrer the DLL and then access it as an automation variable instead of an DotNet variable?

    It could be that the DLL is too old to be used directly as an DotNet variable.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Cannot create an instance of the following .Net framework - Custom DLL - NAV2017

    No it does not, it is just a normal DLL with some Functions in it that we need. I also do really not know what to do anymore.

    Here is a link to the dll https://1drv.ms/u/s!Ar5DM52h81oYgcQ8vbygQ1x0RDDKww

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Cannot create an instance of the following .Net framework - Custom DLL - NAV2017

    Very strange then. Is this an addin that requires a particular setup for installing it?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Cannot create an instance of the following .Net framework - Custom DLL - NAV2017

    Hello Stefano

    Thanks for the answer, yes I know the difference between RunOnclient Yes and No and tired both scenarios and both did give the error.

    I also re added the reference multiple times and also restarted the nav service.

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,162 Most Valuable Professional on at
    RE: Cannot create an instance of the following .Net framework - Custom DLL - NAV2017

    If the DLL is in the addin folder of the client, RunOnClient must be YES. If it's placed in the add-in folder of the service tier, RunOnClient must be set to FALSE.

    Have you ried to re-add the reference after placing the dll in the addin folder?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans