DotNet dll can run in 2013R2 but fails in 2016 / 2018 / BC14, why?

CarlOCarlO Member Posts: 3
Hi!
I have have so far never needed to ask for help but right now i have hit the wall regarding this. Hope i am posting this in the correct place.

Background
We are upgrading a customers solution to BC14, its a very big customization with multiple custom DLL files in the Add-in catalog of the server. These DLL's are from around 2014 when the customer went live and the source code seems to be lost. So far all of these DLL files have continued working in the target environment of BC14 on new servers except 1 that is the most important. The DLL file is custom but it have dependencies on 3 other DLL files from other companies.

The DLL is of processor architecture X86 and dependencies MSIL.

So what is happening?
The DLL file is detected by the development environment and can be assigned to a DotNet variable and the codeunit compiles without errors. However when we create an instance of the object we get the following error message.
Cannot load an instance of the following .NET Framework object: assembly BaxiNav, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a44dfb01592df2b4.

I have attached the full EventView message in the spoiler at the end of this post.

What have we tried
We have tried using the DLL on 2013R2 / 2016 / 2018 /BC14 and the only place it works is on 2013R2. I have on my own local computer right now 2013R2 and 2018 installed at the same time and it still fails on 2018 but works in 2013R2. I have created my own new DLL files of different processor architectures and these can be run without issues so i dont think that is the problem right now. I have placed the DLL on both client and service folder and checked they get synced to client temp folder before every test. I also clear the temp client cache before every run. We have checked the .NET versions of the different server and they are the same but since it does not work on my local machine with the different version of NAV it seems installed .NET versions are not the issue. We have also checked file permissions to make sure the DLL's are not blocked.

Something that is interesting is that yesterday we had another DLL causing the same issue however this one was just developed and we had the code. This one could not be run on in 2013R2 or 2018 for me but after i took the code myself and created another DLL from my own computer it worked to create an instance of the object. After that we had another issues that was caused by a dependency that was for another .NET version. I got everything working from my end and sent the project to my collègue that built a new DLL. My collègues DLL did not work while mine still did with 100% identical code and build parameters. Only difference here is that i build mine with VS Code and he used Visual Studio. This is now solved since we are running with my DLL file but we can not explain why mine works even on customer servers. Feel like the issue we had here could be related.

My thoughts right now
Currently it feels like the only reason for this is the NAV version. I can not find any other reason for this since it works on my computers 2013R2 but at the same time fails in 2018. I have not found anyone describing this scenario on the internet so far but there are some others getting the same error message for other reasons. My hypothesis is that the NAV version is forcing DLL's to run on different .NET versions there creating this issue no matter what version is installed on the computer.

Does anyone have experience with a similar issue?

Thanks your help, solving this would probably save us from over 200 - 300h of work.
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"&gt;
- <System>
<Provider Name="Microsoft-DynamicsNAV-Common" Guid="{e8077de8-19f5-54b6-abca-708d7816893f}" />
<EventID>705</EventID>
<Version>2</Version>
<Level>3</Level>
<Task>33</Task>
<Opcode>0</Opcode>
<Keywords>0x8000f00000000001</Keywords>
<TimeCreated SystemTime="2020-05-07T06:26:10.720916200Z" />
<EventRecordID>543</EventRecordID>
<Correlation />
<Execution ProcessID="27408" ThreadID="27988" />
<Channel>Microsoft-DynamicsNAV-Common/Admin</Channel>
<Computer>*******</Computer>
<Security UserID="S-1-5-20" />
</System>
- <EventData>
<Data Name="instanceName">DynamicsNAV110SE</Data>
<Data Name="navTenantId" />
<Data Name="category">Runtime</Data>
<Data Name="clientSessionId">{d9f693b9-07d5-4e77-9605-cfe95bec8460}</Data>
<Data Name="clientActivityId">{4929fefc-147c-470e-b072-830af84c1614}</Data>
<Data Name="serverSessionId">{00000000-0000-0000-0000-000000000000}</Data>
<Data Name="serverActivityId">{00000000-0000-0000-0000-000000000000}</Data>
<Data Name="eventTime">2020-05-07T06:26:10.720209900Z</Data>
<Data Name="message">(NavNCLDotNetCreateException): Please look in TransientTelemetry for further details. Exception: NavNCLDotNetCreateException Cannot load an instance of the following .NET Framework object: assembly BaxiNav, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a44dfb01592df2b4. ExceptionStackTrace: at Microsoft.Dynamics.Nav.Service.ServiceCall.GetClientReturnValue(Action invokeCallback) at Microsoft.Dynamics.Nav.Service.NSClientCallback.CreateDotNetHandle(String assemblyFullName, String typeName, Guid formHandle, String varName, Boolean createInstance, Object[] arguments) at Microsoft.Dynamics.Nav.Runtime.NavDotNet.CreateDotNet(Object[] arguments) InnerException: Exception: NavNCLDotNetCreateException Cannot load an instance of the following .NET Framework object: assembly BaxiNav, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a44dfb01592df2b4. ExceptionStackTrace: at Microsoft.Dynamics.Nav.Types.NavAutomationHelper.GetAssembly(String assemblyFullName) at Microsoft.Dynamics.Nav.Types.NavAutomationHelper.GetTypeFromAssembly(String assemblyFullName, String typeName) at Microsoft.Dynamics.Nav.Types.NavAutomationHelper.CreateDotNetObject(String assemblyFullName, String typeName, Object[] arguments) at Microsoft.Dynamics.Nav.Client.AutomationHandler.CreateDotNetHandleCore(String assemblyFullName, String typeName, Guid formHandle, String varName, Boolean createInstance, NavAutomationArgument[] arguments) at Microsoft.Dynamics.Nav.Client.AutomationHandlerBase.CreateDotNetHandle(String assemblyFullName, String typeName, Guid formHandle, String varName, Boolean createInstance, NavAutomationArgument[] arguments) at Microsoft.Dynamics.Nav.Client.ServiceClientCallback.<>c__DisplayClass47_0.<CreateDotNetHandle>b__0() at Microsoft.Dynamics.Nav.Client.ServiceClientCallback.<>c__DisplayClass14_0.<RunClientRequest>b__0() at Microsoft.Dynamics.Nav.Client.ServerInvocationManager.DoClientRequestAndCatch(Action clientRequest, Action`1 sendToServerIfNotFaulted) InnerException: Exception: FileNotFoundException ExceptionStackTrace: at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.Load(String assemblyString) at Microsoft.Dynamics.Nav.Types.NavAutomationHelper.GetAssembly(String assemblyFullName) CallerStackTrace: at Microsoft.Dynamics.Nav.Diagnostic.NavDiagnostics.ComposeAndSendExceptionTraceTag(String tag, Category category, Exception exception, DiagnosticParameter parameter, Verbosity verbosity, Guid clientSessionId, Guid clientActivityId, Boolean forceLog) at Microsoft.Dynamics.Nav.Diagnostic.NavDiagnostics.SendExceptionTag(String tag, Category category, Exception exception, Verbosity verbosity, DiagnosticParameter message, Boolean forceLog) at Microsoft.Dynamics.Nav.Runtime.NavDotNet.CreateDotNet(Object[] arguments) at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit50000.OnRun_Scope.OnRun() at Microsoft.Dynamics.Nav.Runtime.NavMethodScope.Run() at Microsoft.Dynamics.Nav.BusinessApplication.Codeunit50000.OnRun(INavRecordHandle εrec) at Microsoft.Dynamics.Nav.Runtime.NavCodeunit.DoRun(DataError errorLevel, NavRecord record) at Microsoft.Dynamics.Nav.Runtime.NavCodeunit.InvokeRun(Int32 objectId, Object[] args) at Microsoft.Dynamics.Nav.Service.NSCodeUnit.RunCodeunit(CodeUnitResponse codeUnit) at Microsoft.Dynamics.Nav.Service.NSCodeUnit.Invoke() at Microsoft.Dynamics.Nav.Service.NSService.InvokeApplicationMethod(ApplicationMethodRequest applicationMethodRequest, NavRecordState state) at SyncInvokeInvokeApplicationMethod(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.RunInTransactionCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass25_1.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.TransientErrorRetryCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass25_1.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.ErrorMappingCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass25_1.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.PushPopCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass25_1.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.TraceScopeCombinator(Category telemetryCategory, ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass25_1.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass10_0.<PerformanceCounterCombinator>b__0() at Microsoft.Dynamics.Nav.Runtime.NavPerformanceCounterSetter.UpdatePerformanceCountersWithAverageServiceOperationDuration(Stopwatch stopWatch, Action action) at Microsoft.Dynamics.Nav.Runtime.NavPerformanceCounterSetter.UpdatePerformanceCountersWithAverageServiceOperationAction(Action action, NavSession session) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.PerformanceCounterCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass25_1.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.InitClientTelemetryIdsCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass25_1.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.TlsClearCombinator(ServiceOperation innerOperation, NSServiceBase serviceInstance, MethodBase syncMethod, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.<>c__DisplayClass25_1.<Combine>b__1(NSServiceBase serviceInstance, Object[] inputs, Object[]& outputs) at Microsoft.Dynamics.Nav.Service.ServiceOperationInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet) at System.ServiceModel.Dispatcher.MessageRpc.Wrapper.Resume(Boolean& alreadyResumedNoLock) at System.ServiceModel.Dispatcher.ThreadBehavior.ResumeProcessing(IResumeMessageRpc resume) at Microsoft.Dynamics.Nav.Runtime.NavSynchronizationContext.<>c__DisplayClass1_0.<ClearThreadLocalStorageDelegate>b__0(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch()</Data>
<Data Name="processId">27408</Data>
<Data Name="tag">000016K</Data>
<Data Name="threadId">38</Data>
<Data Name="counterInformation" />
<Data Name="alternateTenantIds" />
<Data Name="platformVersion">11.0.39505.0</Data>
<Data Name="privacyClassification">800</Data>
<Data Name="aadTenantId" />
</EventData>
</Event>

Answers

  • xStepaxStepa Member Posts: 106
    Hi, the DLL has to be a 64bit version, as the NST process also is.
    Regards
    xStepa
  • CarlOCarlO Member Posts: 3
    edited 2020-05-07
    @xStepa

    My thinking is that since i select "RunFromClient" and i have placed the DLL in the client Add-in folder.
    C:\Program Files (x86)\Microsoft Dynamics NAV\110\RoleTailored Client\Add-ins

    It should be run as a 32bit, if i placed it in the service Add-ins folder i could understand why it does not work since that is 64bit.

    How come i get this issue even if the DLL is in the x86 folder and is run from client? Does the NST process override this is some way?

    Update:
    I just compared the actual client processes of 2018 and 2013R2. The client for 2013R2 runs as 32bit however 2018 runs as 64bit. Seems like this is the issue, i just assumed the client was 32bit because it is installed in that location. Think that is a bit strange that it is installed in the x86 folder however runs as 64bit.
  • CarlOCarlO Member Posts: 3
    Solution to the issue can be found here. It seems that 32 and 64 bit clients and installed in the same location and the system defaults to 64bit if available.

    https://docs.microsoft.com/en-us/dynamics-nav/running-32-bit-microsoft-dynamics-windows-client-on-64-bit-windows

Sign In or Register to comment.