I am trying to pass a COM object from C # code to Perl.
Im currently wrapping my Perl code with PerlNET (PDK 9.4, ActiveState), and I defined a simple routine (+ required pod declaration) in Perl to pass objects from C # to the wrapped Perl module.
It seems that the objects I pass are not recognized correctly as COM objects.
Example:
In C # (.NET 4.0), ScriptControl is used to load a simple class from a file written in VBScript.
var host = new ScriptControl();
host.Language = "VBScript";
var text = File.ReadAllText("TestScript.vbs");
host.AddCode(text);
dynamic obj = host.Run("GetTestClass");
What I get ( obj
) is of type System.__ComObject
. When I pass it to my Perl / PerlNET assembly and try to call the method Xyz()
in Perl, I get the following (runtime) exception:
Can't locate public method Xyz() for System.__ComObject
, , Perl, . ( , .vbs .)
script:
sub UseScriptControl {
my ($self, $text) = @_;
my $script = Win32::OLE->new('ScriptControl');
$script->{Language} = 'VBScript';
$script->AddCode($text);
my $obj = $script->Run('GetTestClass');
$obj->Xyz();
}
Xyz()
obj
( Win32:: OLE).
:
use strict;
use Win32;
use Win32::OLE::Variant;
:
, InvokeMember
System.Type
, , , Im :
use PerlNET qw(typeof);
typeof($obj)->InvokeMember("Xyz",
PerlNET::enum("System.Reflection.BindingFlags.InvokeMethod"),
PerlNET::null("System.Reflection.Binder"),
$obj,
"System.Object[]"->new());
Perl. ..
, .NET 4.0, Perl ( Win32:: OLE), PerlNET COM.
, dynamic
#/.NET 4.0.
, , COM- , Win32::OLE
. , __ComObject
, COM.
, PDK ( ): http://community.activestate.com/node/18247
PerlMonks - , Perl #/. NET:
http://www.perlmonks.org/?node_id=1146244
- , .