//***
where varArray is DotNet array of type => System.Array.’mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′
***//
//*** On calling this COPYTO function I get error
I get an error message that call is ambiguous between following methods i.e.
=> CopyTo(ManagementBaseObject[], int)
and
=>CopyTo(System.Array, int)
***//
WITH ManagementObjectCollection DO BEGIN Enumerator := ManagementObjectCollection.GetEnumerator(); WHILE(Enumerator.MoveNext()) DO BEGIN ManagementObject := Enumerator.Current; PrinterNameTmp := FORMAT(ManagementObject.GetPropertyValue('Name')); MESSAGE(PrinterNameTmp); IF PrinterNameTmp = PrinterName THEN BEGIN ManagementObject.InvokeMethod('SetDefaultPrinter', ObjectArray); EXIT; END; END; END;
Answers
varArray := varArray.CreateInstance(ManagementObjectCollection.GetType(), Count);
try:
varArray := varArray.CreateInstance(ManagementObject.GetType(), Count);
hope it helps.
Oli