External DLL - integration with NAV2017

KeptyKepty Member Posts: 54
edited 2018-09-24 in NAV Three Tier
Hi everyone,

I am having trouble solving this issue and welcome any ideas.

(I am running NAV 2017 32-bit version - my DLL and all its dependencies are 32-bit.)

I have created a codeunit that uses a DLL - and everything works great on my machine. I have copied all of the necessary DLLs to customer's server and local Addin folders - and it does not work on their computer - I get an Error:

Can not load an ..... instance of the following .N E T Framework object ...

The DLL listed in this error is not the one I am using in the code directly but one of the dependencies - but it is also copied in all necessary locations.

Everything works great after I repeated the process on my coworker's computer - connected to the customer's server.

And, after some experimenting, I was able to make it work on the customer's computer as well. So what is the problem then? It only works when I run my codeunit from the Development Environment first.

The process to make it "work" on the customer's pc is:
  1. Launch NAV client (32-bit).
  2. Launch Development Environment
  3. Run my Codeunit from Development Environment -> the function called in OnRun executes correctly
  4. Run the same function from an action in NAV client -> function executes correctly

Without the third step, I always run into the "Cannot load an instance ..." error. After restarting the client application the error comes back.

So to sum things up:
  • Everything works on my laptop from locally-hosted NAV server
  • Everything works on my laptop from customer's NAV server
  • Everything works on my coworker's pc from customer's NAV server
  • Everything works on customer's pc - but only when first executed from Development Environment

I hope this is not too convoluted.

I am lost here. I am thinking it is some windows security related issue? I do not know that much about that though. I will be happy to try out any ideas you throw at me.

Tomáš Kapitán

Answers

  • KeptyKepty Member Posts: 54
    I have posted this article 6 times because of some spam protection, so I am sorry for other unapproved tickets that may show.
    Tomáš Kapitán
  • KTA8KTA8 Member Posts: 388
    are you run on client or not?
  • KeptyKepty Member Posts: 54
    Yes
    Tomáš Kapitán
  • KTA8KTA8 Member Posts: 388
    I guess you're using different permission for run by development and client. Have you tried to use the same user in both test?
  • KeptyKepty Member Posts: 54
    Hi KTA8,
    Yes, we tried to use the cashier account with their permissions and our account that had SUPER permission and AD sysadmin permissions. Both accounts had the same problem.

    T.
    Tomáš Kapitán
  • KTA8KTA8 Member Posts: 388
    Who is the user that works?
  • KeptyKepty Member Posts: 54
    There is not working account. All accounts have the same problem.
    Tomáš Kapitán
  • AgannaloAgannalo Member Posts: 12
    What about registering .dll with regasm.exe? Don't know is it a still problem but when i worked with .dll few years ago this was required to run it.
  • KeptyKepty Member Posts: 54
    It's not neccessary to register the DLL (as mention by Microsoft in some articles - we only added the DLL to add-ins folder on the server).

    We have more integrations to the different platforms (e-sign, pdf printer, debit card terminals...) that work well.
    Tomáš Kapitán
  • xStepaxStepa Member Posts: 106
    is the codeunit with function single instance?
    or is the DevEnv on the same NST as the client?
    (when you run it from DevEnv, it opens on predefined NST)

    if you mentioned same function - you mean the same code and variables or exactly pure function call?
    Regards
    xStepa
  • fsqqfsqq Member Posts: 3
    Hi xStepa,

    Kepty's colleague here.

    The CU is not single-instance.
    It is on the same NST client - the exact steps are:
    • Launching the NAV client - 32bit
    • Launching DevEnv
    • Running the codeunit in DevEnv -> it runs in the already running client
    • Using the Action in the client that runs the same codeunit
    In both cases it's the same function - the action in the client is just simple codeunit.run().
Sign In or Register to comment.