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:
- Launch NAV client (32-bit).
- Launch Development Environment
- Run my Codeunit from Development Environment -> the function called in OnRun executes correctly
- 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.