title: HTTP Status 502 error when returning string from C DLL to C# DLL on Windows Server 2012
body: <p>I'm working on setting up an old C# DLL (written in Visual Studio 2003) on a server running Windows Server 2012 R2. The DLL is raising an error when it calls a C DLL (also compiled using Visual Studio 2003) which returns a string. The error message raised when the C DLL attempts to return the string is as follows:</p>
  
  <blockquote>
    <p>System.Net.WebException: The request failed with HTTP status 502:
    Proxy Error ( The specified network name is no longer available. ).</p>
  </blockquote>
  
  <p>The code runs without any issues on XP and on Windows 7, and the C# DLL is being executed by an ASP.NET web service.</p>
  
  <p>The relevant C# code is as follows:</p>
  
  <pre><code>[DllImport("ESConnect.dll", SetLastError=false, CharSet=CharSet.Ansi)]
  private static extern StringBuilder EsGetText(ref StringBuilder name, ref StringBuilder strReturned, ref size);
  .
  .
  .
  StringBuilder sbReturned = new StringBuilder();
  StringBuilder sbTemporary = new StringBuilder();
  
  sbTemporary=EsGetText(ref sbName, ref sbReturned, ref size);
  </code></pre>
  
  <p>And the C code, for the function EsGetText, is:</p>
  
  <pre><code>FNEXPORT( PSZ __stdcall, EsGetText )( PSZ *ppszName, PSZ *ppszValue, PSHORT psSize)
  {
    PFILE   pFile    = NULL;
  
    gdClock = USE( gdClock, fnTime() );
  
    TbxGetText( *ppszName, *ppszValue, (SHORT)( psSize ? *psSize : 0 ) );
  
     return( *ppszValue );
  }
  </code></pre>
  
  <p>I can tell from logging that I added that EsGetText is successfully populating the value in ppszValue but once the return command is executed the "HTTP status 502" error is raised.</p>
  
  <p>Any ideas at all as to what might be causing this issue are more than welcome.
  Thanks.</p>