Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

The Microsoft Dynamics NAV Application Server (NAS) hangs when you work with external components


View products that this article applies to.

Symptoms

The Microsoft Dynamics NAV Application Server (NAS) hangs when it tries to access a function in an external component. In this context, an external component is a variable of type OCX or Automation. When this happens, the only way to stop the NAS is to terminate the process (Nassql.exe) from Task Manager.

This problem only happens in Microsoft Dynamics NAV 2009 R2. It does not happen in Microsoft Dynamics NAV 2009 SP1 or previous versions.

Also, the problem only happens when the NAS is running as a service. It does not happen if the NAS is started from a command prompt.

↑ Back to the top


Cause

As part of ongoing work for better .NET integration, one change made in Microsoft Dynamics NAV R2 is that when the NAS is running as a service, the NAS thread that executes C/AL code is no longer the main STA thread. This has been shown to be a problem with some (mainly older) external components. The NAS may be able to create an instance of such a component, but soon after, the NAS process may hang.

↑ Back to the top


Resolution

The solution to this problem is to make the external component compatible with the new threading behavior in the NAS. This can be done either by changing the external component - if the source code is available - to specifically use threading model "Apartment", or by using the registry to set the threading model to "Apartment".

To use the registry to change threading behavior of an external component, you must first locate the path where the component is located in the registry. For example, this could be:

HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{E7414D60-2D83-44C7-826A-FD14557299F0}

Then, you must locate the subkey "InprocServer32", and under this key create a new string value (Reg_SZ) called "ThreadingModel", and set the value in the string value to "Apartment".

↑ Back to the top


More Information

If you do not know where in the registry a certain component is located, you can use Process Monitor to locate it. Follow these steps to locate the component:
  1. Collect a trace while the problem happens
  2. Search the trace (Ctrl + F) for "ThreadingModel"
  3. Process Monitor should show under which key in the registry the NAS is trying to locate the key

For more information about changing threading models, click this link:
DOC: ThreadingModel Is Not a Subkey

For more information about COM threading models, click this link:
Understanding and Using COM Threading Models

For more information about different threading models, click this link:
INFO: Descriptions and Workings of OLE Threading Models

↑ Back to the top


Keywords: kbmbspartner, kbmbsmigrate, kbsurveynew, kb

↑ Back to the top

Article Info
Article ID : 2621394
Revision : 1
Created on : 1/7/2017
Published on : 9/22/2011
Exists online : False
Views : 340