title: Run-time Error 458, Variable uses an Automation Type not supported in Visual Basic
body: <p>Basically, I'm getting this error when I try to call a function inside the upnp.dll using VB6, where upnp.dll is returning a datatype that is not supported by VB6. Previously, this same error occured but on a different function/variable, and the resolution was to open up upnp.dll in oleview.exe (to view Type Library Information) and to replace all occurences of "Unsigned Long" with just "Long" and then compile a new TypeLib with the "Unsigned" keywords removed, this solved the problem for that senario.</p>
  
  <p>Now, I need to solve the same problem but for a different function/variable, but the problem is, I have no idea which variable datatype I need to change or remove when I'm in oleview's TypeLib view of upnp.dll.</p>
  
  <p>For completeness, I'll let you know where this error is occuring, and then I will show you the relevant part of the oleview/TypeLib view that I am having trouble modifying. (for your information, upnp.dll is contained in windows\system32 and oleview.exe comes with the Windows SDK Toolkit if you do not already have it on your machine).</p>
  
  <p>I am calling the function <code>.InvokeAction sActionName, aryIns, aryOuts</code> where aryIns and aryOuts are Variants declared like this: <code>Dim aryIns As Variant, aryIns As Variant</code> - basically, I declare it generally, put any input data I need inside aryIns and I will get aryOuts with the results of the InvokeAction call. The good thing is, InvokeAction turns my general Variant into a properly dimensioned array reflecting the number of output items that are returned for the ActionName I'm using.</p>
  
  <p>Re the point I'm getting the error, I am using (for sActionName) "GetStatusInfo" on a "WanIPConnection" under the "WAN Connection Device". I don't need to define any items for aryIns since this call doesn't require or need any input arguments, but it provided (returns) 3 items (results) and puts them in aryOuts. So aryOuts ends up as an array with items from index 0 to 2 (3 items total)... and when I loop through this aryOuts array, the items 0 and 1 are printed out and viewed perfectly (without problems) but on the 3rd item (aryOuts(2)) I get the above exception.</p>
  
  <p>Basically, the first 2 arguments are just simple strings (no problem accessing these) but the 3rd argument is defined by the UPnP people as an <code>Unsigned 4 Byte Integer</code> (and this is where the problem lays), VB6 is unable to interpret this datatype and is not letting me access this array item (aryOuts(2)), and I could not figure out what part of the TypeLib I need to modify, since the definition for InvokeAction aryOuts is just stated as a VARIANT* in the TypeLib, and here is the relevant part of the TypeLib for your view (I've included the area I understand to be relevant, if you would like additional areas posted, let me know and I can do this):</p>
  
  <pre><code>[
    odl,
    uuid(A295019C-DC65-47DD-90DC-7FE918A1AB44),
    helpstring("IUPnPService Interface"),
    dual,
    nonextensible,
    oleautomation
  ]
  interface IUPnPService : IDispatch {
      [id(0x600209c5), helpstring("method QueryStateVariable")]
      HRESULT QueryStateVariable(
                      [in] BSTR bstrVariableName, 
                      [out, retval] VARIANT* pValue);
      [id(0x600209c6), helpstring("method InvokeAction")]
      HRESULT InvokeAction(
                      [in] BSTR bstrActionName, 
                      [in] VARIANT vInActionArgs, 
                      [in, out] VARIANT* pvOutActionArgs, 
                      [out, retval] VARIANT* pvRetVal);
      [id(0x600209c7), propget, helpstring("property ServiceTypeIdentifier")]
      HRESULT ServiceTypeIdentifier([out, retval] BSTR* pVal);
      [id(0x600209c8), helpstring("method AddStateChangeCallback")]
      HRESULT AddCallback([in] IUnknown* pUnkCallback);
      [id(0x600209c9), propget, helpstring("property Id")]
      HRESULT Id([out, retval] BSTR* pbstrId);
      [id(0x600209ca), propget, helpstring("property LastTransportStatus")]
      HRESULT LastTransportStatus([out, retval] long* plValue);
  };
  </code></pre>
  
  <p>The aryOuts() array I was talking about before is defined by the <strong><code>[in, out] VARIANT* pvOutActionArgs</code></strong> line in the <strong><code>InvokeAction</code></strong> declaration (in the TypeLib above). Basically, the whole array is defined as a VARIANT* (which is fine) but I am having trouble accessing the 3rd element (index item number 2) of the <code>pvOutActionArgs</code> array defined above, how do I modify the TypeLib around this problem?</p>
  
  <p><em>For reference, and those of you that are interested, Hans Passant (@HansPassant) helped me in solving the similar scenario by asking me to remove the Unsigned section of Text from the upnp.dll TypeLib exposed by oleview.exe - he helped me do this (and the rest of the steps necessary to produce and compile the new TypeLib (upnp.tbl) in the following post:</em> <a href="https://stackoverflow.com/questions/3965767/function-or-interface-marked-as-restricted-or-the-function-uses-an-automation-t">Function or interface marked as restricted, or the function uses an Automation type not supported in Visual Basic</a></p>