locked
ACK failure on C++/CX WinRT component with "In/out parameters are not supported."

    Question

  • Hi,
    I have a HTML/JS Metro Style Device App that includes a C++/CX WinRT component dll that provides the interface to the device driver. I was running the ACK on the app package and it failed the metadata correctness test, mainly because of the WinRT component. I am using the latest version of the SDK and ACK (Aug 15th 2012 release).
    The ACK is complaining about all public APIs that take any non-array parameters. Essentially if any API takes a numeric type as a parameter or a String reference, that is reported as a failure. This is even though I have marked the parameters as __in.

    Here's a couple of examples:
    public property definition:
    property INT32 ServiceId {INT32 get(); void set(__in INT32 svcId);}
    ACK error:
    Parameter svcId of method set_ServiceId of the MyAppRT.__IMyAppPublicNonVirtuals type in file C:\Program Files\WindowsApps\MyApp_3.0.40.6_x64__6bnhxwy1xhb3j\MyApp.winmd is an in/out parameter. In/out parameters are not supported.

    public method definition:
    void SetDeviceId(__in String^ DevId);
    ACK error:
    Parameter ihaDevId of method SetIhaDeviceId of the MyAppRT.__IMyAppPublicNonVirtuals type in file C:\Program Files\WindowsApps\MyApp_3.0.40.6_x64__6bnhxwy1xhb3j\IHART.winmd is an in/out parameter. In/out parameters are not supported.

    Similar errors are thrown as well even for delegates that take references to sealed classes as parameters.
    I understand arrays cannot be passed as in/out across the ABI but could not understand why numerical types and strings will also have the same issue. I would very much appreciate any help with this error. 


    Rahul Ghosh

    Thursday, August 23, 2012 11:50 PM

Answers

  • This is your problem:

    Visual Studio Ultimate 2012 RC version 11.0.5052

    That's the release preview version of visual studio.  You need to be running the RTM version of Visual studio.  Your problem is a known bug that was fixed between RC and RTM.

    Wednesday, August 29, 2012 12:58 PM

All replies

  • Hi Rahul,

    Can you share the winmd file for us to take a look?

    Thanks.

    -Bobby

    Tuesday, August 28, 2012 8:16 PM
  • Can you please send the IHART.winmd file? Without the winmd file it's not easy to determine the root cause.

    Alternatively, you can open the .winmd file in the ildasm tool, navigate to the IMyAppPublicNonVirtuals interface and cut&paste the declaration for the set_ServiceId method and the SetIhaDeviceId method?

    My suspicion (and it's only a suspicion) is that you're using SAL annotations (__in) instead of type annotations [in] and the C++ compiler is getting confused by the SAL annotation (the C++ compiler normally adds the "in" attribute for you, but it's possible that the SAL annotation is confusing it).

    Tuesday, August 28, 2012 8:17 PM
  • Thanks for the response. I have tried both with and without SAL annotation, did not make a difference though. The same ACK failures showed up.

    Here's the declarations from ildasm you requested:

    .method public newslot abstract virtual instance void 
            SetIhaDeviceId(string ihaDevId) cil managed
    {
    } // end of method __IIhaRtPublicNonVirtuals::SetIhaDeviceId

    .method public newslot specialname abstract virtual 
            instance void  set_ihaServiceId(int32 svcId) cil managed
    {
    } // end of method __IIhaRtPublicNonVirtuals::set_ihaServiceId


    Rahul Ghosh

    Tuesday, August 28, 2012 10:36 PM
  • Try adding the [in] attribute to your parameters, for some reason they're not showing up in the metadata.
    Tuesday, August 28, 2012 11:32 PM
  • Do I need to create an IDL file for this? Adding [in] to the parameter in the method declarations in the header file throws a compilation error.

    BTW, I am following the CustomDeviceAccess sample (http://code.msdn.microsoft.com/windowsapps/Custom-device-access-sample-43bde679) as an example for WinRT component development. When ran the ACK on the sample app it throws the same errors as well.

    Rahul Ghosh

    Wednesday, August 29, 2012 1:48 AM
  • You shouldn't need to use an IDL file (using an IDL file gets *very* confusing). I have no idea why the C++ compiler isn't adding the "in" attribute, but if you add [in] to your parameters, it should fix the issue.  You may have to spell "in" as "In" (not sure if the C++ compiler treats the attribute as case sensitive or if it has an alternative spelling).

    Btw, I'm surprised that the CustomDeviceAccess sample fails to pass the WACK - as a part of our daily test passes, we make sure that our samples compile every day in our build labs and that they pass the WACK.

    Have you made sure that you're running the RTM version of the C++ compiler? There were a significant number of fixes made to the C++ compiler between the Release Preview and RTM that could absolutely cause WACK failures.


    Wednesday, August 29, 2012 3:24 AM
  • Thanks for the prompt responses Larry, very much appreciated.

    I did check that I have the RTM versions of the SDK and VS2012.
    Here's what I have on my Win8 build and test machine:
    Windows SDK version 8.59.25584
    Visual Studio Ultimate 2012 RC version 11.0.5052
    Microsoft Visual C++ 2012 RC   04166-004-0009005-02392 (reported in VS2012 about box)
    Are these the right versions?

    The compiler is not accepting either 'in' or 'In'. Only SAL annotations (__in, __out) are being accepted and that is not making a difference with the WACK. I checked the WinRT component in the CustomDeviceAccess sample and that's using SAL annotations as well. 
    WACK is throwing very much the same errors for the Samples.Devices.Fx2 WinRT component as well:

    • Parameter value of method set_SevenSegmentDisplay of the Samples.Devices.Fx2.__IFx2DevicePublicNonVirtuals type in file C:\Program Files\WindowsApps\Microsoft.SDKSamples.CustomDeviceAccess.CS_1.0.0.0_x86__s9y1p3hwd5qda\Samples.Devices.Fx2.winmd is an in/out parameter. In/out parameters are not supported.
    • Parameter __param1 of method add_SwitchStateChanged of the Samples.Devices.Fx2.__IFx2DevicePublicNonVirtuals type in file C:\Program Files\WindowsApps\Microsoft.SDKSamples.CustomDeviceAccess.CS_1.0.0.0_x86__s9y1p3hwd5qda\Samples.Devices.Fx2.winmd is an in/out parameter. In/out parameters are not supported.
    • Parameter __param0 of method remove_SwitchStateChanged of the Samples.Devices.Fx2.__IFx2DevicePublicNonVirtuals type in file C:\Program Files\WindowsApps\Microsoft.SDKSamples.CustomDeviceAccess.CS_1.0.0.0_x86__s9y1p3hwd5qda\Samples.Devices.Fx2.winmd is an in/out parameter. In/out parameters are not supported.
      ............................


    Rahul Ghosh

    Wednesday, August 29, 2012 6:19 AM
  • This is your problem:

    Visual Studio Ultimate 2012 RC version 11.0.5052

    That's the release preview version of visual studio.  You need to be running the RTM version of Visual studio.  Your problem is a known bug that was fixed between RC and RTM.

    Wednesday, August 29, 2012 12:58 PM
  • Thanks! Upgrading to the RTM version solved the issue. App passes WACK now.

    Rahul Ghosh

    Thursday, August 30, 2012 4:51 PM