Results 1 to 3 of 3
  1. #1

    Using C# collections

    Hi all,

    Given that a response to my previous post - "Calling C# from scripts" - indicated that using C# DLLs is possible from TestPartner, I created a my first script and not long after encountered my first big hurdle!

    I added a reference to my script by using a type library i.e. the TLB file, and wrote the following script:

    Dim mc As IMyCollection
    Set mc = myObject.collection
    Dim o As Object
    For Each o in mc <--- error occurs here!
    MsgBox "in loop"

    When executing the script, the following error gets displayed consistently:

    "Run-time error '438':
    Object doesn't support this property or method"

    Using the Object Browser to investigate IMyCollection revealed that all collection methods for this interface are missing! The weird thing is that I have successfully used the same DLL from C# and VB.NET without any problems.

    Am I missing something here? Can anyone see problems with my script? Or is there something fundamentally wrong with what I'm doing?

    Please help,

  2. #2

    Re: Using C# collections

    I should clarify one thing that I didn't explain clearly in my previous post. My C# application has the following interface:

    public interface IMyCollection : ICollection, IEnumerable
    object this[int id];

    The Object Browser does contain Item, Function1 and Function2 methods, but does not include any of the inherited interfaces (such as GetEnumerator). I suspect that if GetEnumator was show within the Object Browser, then For Each...Next would work successfully.

  3. #3

    Re: Using C# collections

    You definetely need the Enumerator methods implemented if you're using "For Each". I think you're correct about your suspicions [img]images/icons/smile.gif[/img]



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:43 PM.

Copyright BetaSoft Inc.