The C # WPF application I am working in contains many calls to an unmanaged external DLL. All calls to the DLL work as expected during normal operation of the application (that is, outside the Visual Studio debugger). However, when debugging from Visual Studio 2013, calling one specific method in the DLL causes the application to crash:

This is how I import the method:
[DllImport("Client.dll", CallingConvention = CallingConvention.Cdecl)] private static extern string ClientGetVersion();
... and so I call the DLL method:
try { version = ClientGetVersion(); } catch (Exception ex) {
Visual Studio seems to use the vshost32.exe process to host applications during a debugging session ( VSHOST is the hosting process ). In addition, “When invoking certain APIs, it may be affected when the hosting process is enabled.” In these cases, you must turn off the hosting process in order to return the correct results. "(See the MSDN article How to turn off the hosting process .) Disabling the" Enable Visual Studio Hosting Process "option in Project> Properties ...> Debug, as shown below, really eliminates problem:

Can anyone understand what specifically can cause this problem with "... calls to specific APIs ..."?
source share