Home > Enterprise >  My.Computer.Info.OSFullName causes a System.Exception
My.Computer.Info.OSFullName causes a System.Exception

Time:09-15

In my VB.NET app using .NET Framework 4.5 I have this line of code:

ThisOS.Text = My.Computer.Info.OSFullName

It has been working as expected without problems. Suddenly yesterday a client using 9 x Windows 10 machines reports an unhandled exception on 2 of them which caused the entire app the crash. After much error trapping, recompiling, uploading and installing I eventually pinpointed that line of code as the source of the exception. I changed the code as below and the problem was solved.

' this causes an exception on some computers
Try
    ThisOS.Text = My.Computer.Info.OSFullName
Catch ex As Exception
      ThisOS.Text = "Unknown OS"
End Try

Does anybody know why this happens? I'd like to be able to fix the root cause instead of just catching the error. Exception detail:

System.Exception: Exception of type 'System.Exception' was thrown.
   at SheriffSQL6.FrmAsheriff.FrmAsheriff_Load(Object sender, EventArgs e) in C:\vbcode.net\SheriffSQL6\SheriffSQL6\FrmAsheriff.vb:line 155
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I suggested to reset Windows.

CodePudding user response:

Fortunately it is a documented bug, install WMI to fix it:

https://docs.microsoft.com/en-us/dotnet/visual-basic/misc/could-not-obtain-full-operation-system-name-due-to-internal-error

A call to the My.Computer.Info.OSFullName property failed. A possible cause for this failure is if Windows Management Instrumentation (WMI) is not installed on the current computer.

To correct this error Add a Try...Catch block around the call to the My.Computer.Info.OSFullName property.

For more information about WMI and how to install it, go to and search for "Windows Management Instrumentation Core".

OP mentioned:

After much error trapping, recompiling, uploading and installing I eventually pinpointed that line of code as the source of the exception

Tip to track down these random errors easily, take a look at my "UserActionLog" https://stackoverflow.com/a/30525957/495455

  • Related