// Get the managed command line.
LPCWSTR pCmdLine = GetManagedCommandLine();
+ // If this process started as a service we won't havre a managed command line
+ if (pCmdLine == nullptr)
+ {
+ // Use the result from GetCommandLineW() instead
+ pCmdLine = GetCommandLineW();
+ }
+
S_SIZE_T cCmdLine = S_SIZE_T(wcslen(pCmdLine));
cCmdLine += 1;
if (cCmdLine.IsOverflow())
DiagnosticServer::Shutdown();
#endif // FEATURE_PERFTRACING
+ // When running under FEATURE_PAL, the SetCommandLineArgs call above will
+ // call SaveManagedCommandLine which will allocate memory using new WCHAR[]
+ // We can release this memory now.
+ //
+ ReleaseManagedCommandLine();
+
#if defined(FEATURE_COMINTEROP)
// Get the current thread.
Thread * pThisThread = GetThread();
}
GCPROTECT_END();
-
- // When running under FEATURE_PAL, the SetCommandLineArgs call above will
- // call SaveManagedCommandLine which will allocate memory using new WCHAR[]
- // We can release this memory now.
- //
- ReleaseManagedCommandLine();
}
UNINSTALL_UNWIND_AND_CONTINUE_HANDLER;