Search Unity

NotImplementedException raised when using managed plugin

Discussion in 'Scripting' started by Wolfos, Apr 5, 2018.

  1. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Hi all!

    What I'm trying to do is get the UWF (Universal Write Filter) status in Unity. However, this requires the System.Management namespace, which Mono doesn't implement. So I compiled a DLL with .NET 4.0, but any time I try to call it, it throws a NotImplementedException. What am I doing wrong?

    Here's the plugin's full code:
    Code (CSharp):
    1. using System;
    2. using System.Management;
    3.  
    4. namespace UWFTools
    5. {
    6.     public class UWF
    7.     {
    8.         public static string GetUWFStatus()
    9.         {
    10.             ManagementScope scope = new ManagementScope(@"root\standardcimv2\embedded");
    11.             ManagementClass UWFFilter = new ManagementClass(scope.Path.Path, "UWF_Filter", null);
    12.             ManagementClass UWFOverlayConfig = new ManagementClass(scope.Path.Path, "UWF_OverlayConfig", null);
    13.             ManagementClass UWFOverlay = new ManagementClass(scope.Path.Path, "UWF_Overlay", null);
    14.             ManagementClass UWFServicing = new ManagementClass(scope.Path.Path, "UWF_Servicing", null);
    15.  
    16.             foreach (ManagementObject mo in UWFFilter.GetInstances())
    17.             {
    18.                 if (mo.GetPropertyValue("CurrentEnabled").ToString() == "True")
    19.                 {
    20.                     return "Enabled";
    21.                 }
    22.                 else
    23.                 {
    24.                     return "Disabled";
    25.                 }
    26.             }
    27.  
    28.             return "Unknown";
    29.         }
    30.     }
    31. }
    32.  
     
  2. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Bump
     
  3. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    So I'm thinking the issue is that a DLL can't use functionality unsupported by Mono either.

    I will just pass the UWF status as a command line argument instead.
     
    Last edited: Apr 6, 2018