I am trying to do a little test in vbscript, so I created a very simple DLL in C # (I am new) and want to use it in vbscript.
C # code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace myNamespace
{
public class myClass1
{
public string sVariable1="Variable content";
}
public class myClass2
{
public myClass1 myMethod2(myClass1 test)
{
return test;
}
}
}
and vbscript
Set oClass1 = CreateObject("myNamespace.myClass1")
Set oClass2 = CreateObject("myNamespace.myClass2")
WScript.Echo oClass1.sVariable1
Set return = oClass2.myMethod2(oClass1)
WScript.Echo return.sVariable1
after running vbscript, on the console I have "variable content" displayed by the first echo, and then I have the error "Microsoftsoft vbscript error, execution error, invalid call or procedure argument:" oClass2.myMethod2 ".
Can I pass an object this way?
Referring to note MK2. The problem is not with the return method, because the following code works.
public myClass1 myMethod2()
{
myClass1 test = new myClass1();
return test;
}
and vbs
Set return = oClass2.myMethod2()
now on the console i have
Variable content
Variable content
But how to pass myClass1 object to vbs?
source
share