2dust/v2rayN · warning · ApplicationException
RasEnumEntries failed with error code: {result}
Error message
RasEnumEntries failed with error code: {result} What it means
Thrown when the RAS (Remote Access Service) RasEnumEntries call still returns a non-zero result after the buffer-retry loop. The loop grows the buffer on ERROR_BUFFER_TOO_SMALL/insufficient-buffer, but any other non-zero RAS result is treated as a hard failure.
Source
Thrown at v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs:235
rasEntryNames = new RASENTRYNAME[bufferSize / Marshal.SizeOf(typeof(RASENTRYNAME))];
for (var i = 0; i < rasEntryNames.Length; i++)
{
rasEntryNames[i].dwSize = Marshal.SizeOf(typeof(RASENTRYNAME));
}
result = NativeMethods.RasEnumEntries(null, null, rasEntryNames, ref bufferSize, ref entries);
}
if (result == 0)
{
var entryNames = new List<string>();
for (var i = 0; i < entries; i++)
{
entryNames.Add(rasEntryNames[i].szEntryName);
}
return entryNames;
}
throw new ApplicationException($"RasEnumEntries failed with error code: {result}");
}
#region WinInet structures
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct InternetPerConnOptionList
{
public int dwSize; // size of the INTERNET_PER_CONN_OPTION_LIST struct
public nint szConnection; // connection name to set/query options
public int dwOptionCount; // number of options to set/query
public int dwOptionError; // on error, which option failed
//[MarshalAs(UnmanagedType.)]
public nint options;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct InternetConnectionOptionView on GitHub (pinned to e01717d832)
Solutions
- Decode the RAS result code (RAS error constants) to identify the cause; common non-zero values map to specific RAS errors.
- Ensure the Telephony/RAS services are running (services.msc) on the machine.
- Run with sufficient privileges to enumerate RAS entries.
- If RAS is unavailable, guard the caller to skip PPPoE enumeration (this method supports PPPoE; absence of RAS is acceptable on many systems).
- Catch ApplicationException at the call site and degrade gracefully (return empty list) when RAS is not present.
Example fix
// before - any non-zero RAS result throws
throw new ApplicationException($"RasEnumEntries failed with error code: {result}");
// after - tolerate 'no RAS / no entries' and surface actionable error otherwise
if (result == 0)
return entryNames;
// ERROR_NO_MORE_ITEMS / RAS service absent -> no dial-up entries
return Enumerable.Empty<string>(); Defensive patterns
Strategy: try-catch
Validate before calling
// Only attempt RAS enumeration on Windows where RAS is available if (!OperatingSystem.IsWindows()) return Enumerable.Empty<string>(); // then call EnumerateRasEntries inside a try-catch
Type guard
static bool RasLikelyAvailable() => OperatingSystem.IsWindows();
Try / catch
try
{
var entries = ProxySettingWindows.EnumerateRasEntries();
}
catch (ApplicationException ex) when (ex.Message.Contains("RasEnumEntries"))
{
// RAS service absent/unavailable; PPPoE enumeration not possible, degrade to empty
return Enumerable.Empty<string>();
} Prevention
- Treat RAS absence as non-fatal (return empty list) since many systems have no dial-up entries.
- Decode the RAS result code to identify the specific failure.
- Ensure Telephony/RAS services are running if PPPoE support is required.
- Run with sufficient privileges to enumerate RAS entries.
When it happens
Trigger: EnumerateRasEntries calls RasEnumEntries; after resizing the buffer for the too-small case, result is still != 0 (not success and not a buffer-too-small retry signal).
Common situations: RAS service not running or unavailable on the machine; non-Windows or a Windows edition without RAS; corrupt telephony/RAS configuration; insufficient privileges to enumerate dial-up/PPPoE entries.
Related errors
AI-assisted analysis of 2dust/v2rayN@e01717d832 (2026-08-13).
Data as JSON: /api/errors/e25daf4a62aa21fd.
Report an issue: GitHub.