简体   繁体   中英

HTTP Status 502 error when returning string from C DLL to C# DLL on Windows Server 2012

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:

System.Net.WebException: The request failed with HTTP status 502: Proxy Error ( The specified network name is no longer available. ).

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.

The relevant C# code is as follows:

[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);

And the C code, for the function EsGetText, is:

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 );
}

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.

Any ideas at all as to what might be causing this issue are more than welcome. Thanks.

Set your ASP.Net web service to use an ASP.Net 2.0 app pool. If you do not have any ASP.Net 2.0 app pools available, make sure you have .Net 3.5.2 installed. It sounds like your older web service has some configuration that is not .Net 4 compatible. This is not uncommon, and if you don't need .Net 4, there's really no need to upgrade the code/service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM