none
WCF Interop: VBScript Call Fails on Functions Returning Object RRS feed

  • Question

  • When accessing a particular function (Counts) from an IIS-hosted (localhost) web service using vbscript, I get the following error:

      Error: Type 'System.Object[]' with data contract name
      ArrayOfanyType:http://schemas.microsoft.com/2003/10/Serialization/Arrays'
      is not expected. Add any types not known statically to the list of known
      types ‐ for example, by using the KnownTypeAttribute attribute or by adding
      them to the list of known types passed to DataContractSerializer.
      Code: 8013150C
      Source: System.Runtime.Serialization

      [ComVisible(true)]
      [Guid("852C10F3-EE2E-4476-B70C-914F233360C8")]
      [ServiceContract(Namespace = "http://Tempuri.org/")]
      public interface IService
      {
      ...
        [OperationContract]
        [return: MarshalAs(UnmanagedType.Struct, SafeArraySubType = VarEnum.VT_ARRAY)]
        object Counts(object objFirstParam, 
                      object objSecondParam);
      ...
      }
      ...
      [ComVisible(true)]
      [Guid("078B17FD-66F4-4B75-B88F-66312F142CAD")]
      [ServiceBehavior(Namespace = "http://Tempuri.org/")]
      public class Service : IService
      {
      ...
        public object Counts(object objFirstParam, object objSecondParam)
        {
        ...
          return Result.Cast<object>().ToArray();
        }
      ...
      }

    Other function calls, not returning object, work as expected.

    Please advise?

    matekus


    Illiud Latine dici non potest.


    • Edited by _matekus_ Monday, September 9, 2013 10:06 PM Code error.
    Monday, September 9, 2013 10:00 PM

All replies

  •   Error: Type 'System.Object[]' with data contract name
      ArrayOfanyType:http://schemas.microsoft.com/2003/10/Serialization/Arrays'
      is not expected. Add any types not known statically to the list of known
      types ‐ for example, by using the KnownTypeAttribute attribute or by adding
      them to the list of known types passed to DataContractSerializer.
      Code: 8013150C
      Source: System.Runtime.Serialization

    Hi,

    When occur the above error, please try to add KnownType attribute to your base class as below:

    [DataContract]
    [KnownType(typeof(..))]
    public class YourClassNameHere
    {
    }

    For more information, please try to refer to:

    #Understanding Known Types:
    http://blogs.msdn.com/b/youssefm/archive/2009/04/21/understanding-known-types.aspx .

    #All About KnownTypes:
    http://blogs.msdn.com/b/sowmy/archive/2006/06/06/all-about-knowntypes.aspx .

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 16, 2013 1:07 AM
    Moderator
  • Amy,

    Thanks for the follow-up.

    I have tried many different known types as you suggested but without success. Given the outline code snippet above, what do you believe is missing?

    matekus


    Illiud Latine dici non potest.

    Monday, September 16, 2013 12:37 PM