Search code examples
c#wmicim

Calling CIM method requires a MI_STRINGA data type


From C# I am trying to call a CIM method:

string str = "1.1.1.1";
var param = new CimMethodParametersCollection();
...
param.Add(CimMethodParameter.Create("NotifyServers", str, CimFlags.In));
session.InvokeMethod(_NameSpace, "PS_DnsServerPrimaryZone", "SetByParameters", param);

Problem is it results in the error message: The WinRM client cannot process the request. Property "NotifyServers" with MI type MI_STRING does not match the expected type from the schema: MI_STRINGA. Specify the correct type and retry the operation.

Looks as if it wants an 8-bit/ascii string, but C# operates with unicode strings. How do I give it a MI_STRINGA data type?

I tried byte[] and char[], and pointers to marshaled memory chunks. But it just results in other data types it cannot convert to MI_STRINGA.


Solution

  • Never mind. The A in MI_STRINGA means array, not ASCII or ANSI. So a simple string[] will do....