I have two .NET classes exposed via COM interop - let's say Foo and Bar, and I need to pass an argument of type Foo to a method defined in Bar. Something like this:
[ComVisible(true)]
public class Foo
{
// whatever
}
[ComVisible(true)]
public class Bar
{
public void Method(Foo fff)
{
// do something with fff
}
}
When I run the following VBS (using cscript.exe):
set foo = CreateObject("TestCSProject.Foo")
set bar = CreateObject("TestCSProject.Bar")
call bar.Method(foo)
I get an error:
D:\test.vbs(3, 1) Microsoft VBScript runtime error: Invalid procedure call or argument: 'bar.Method'
However, if I change the Method declaration to this:
public void Method(object o)
{
Foo fff = (Foo)o;
// do something with fff
}
everything works. I tried some magic with interfaces, attributes, etc. but no luck so far.
Any insight?
Many thanks