7

I use VS 2008 and Windows 7.
Got a .NET C# class which is exposed as COM object.

[Guid("E5014B85-FCB2-4F0D-95EC-F741395A7923")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]

public interface DSystem
{

    [DispId(1610809354)]
    void setProperties(IDictionary propertymap);

}

COM object is called from a VBScript

dim dSystem
set dSystem = CreateObject("MYCOMOBJECT")

Dim objDictionary
Set objDictionary = CreateObject("System.Collections.Hashtable")
objDictionary.Add "PROP1", "abc"
objDictionary.Add "PROP2", "zyx"

dSystem.setProperties(objDictionary)

Everything works fine ... but, a return type change from void to bool

    [DispId(1610809354)]
    bool setProperties(IDictionary propertymap);

and

 success = dSystem.setProperties(objDictionary)

causes an error

Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument


The .tlb file seems to be ok

[id(0x6003000a)]
HRESULT setProperties(
[in] IDictionary* propertymap, 
[out, retval] VARIANT_BOOL* pRetVal);


What am i doing wrong?
Can anybody give me a hint?

1
  • 1
    This newbie question is well asked. Commented Feb 3, 2011 at 11:27

1 Answer 1

6

Not sure about this, but I seem to vaguely remember that because VBScript uses only Variants, you need to declare your method parameters as object.

Try

[DispId(1610809354)]      
bool setProperties(object propertymap);

and cast to an IDictionary inside the method body.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.