.NET ComException (0x800706BE) on Windows Server 2012R2 startup when querying Win32_Service

Bernhard Führicht 1 Reputation point
2020-12-14T09:10:05.39+00:00

Hello,

when starting a service automatically on a Windows 2012R2 Server, during the startup of the server the service crashes with the following exception:

Stacktrace:
Exception: System.Runtime.InteropServices.COMException;
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Management.ManagementObjectCollection.ManagementObjectEnumerator.MoveNext()

When the service is set to "Delayed Start" it works and stopping and starting on the running system works too.

During the service start the WMI-Query ("SELECT * FROM Win32_Service WHERE name like '%SERVICE%'") is made using the System.Management.ManagementObjectSearcher and the result set is looped to check if the service is already running.

Regards,
Bernhard

Windows Server 2012
Windows Server 2012
A Microsoft server operating system that supports enterprise-level management, data storage, applications, and communications.
1,588 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,159 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.