Hello!
I'm trying to pass a COM object from C# code to perl.
At the moment I'm wrapping my perl code with PerlNET and I have defined a
simple subroutine to pass objects from C# to the wrapped perl module.
It seems that the objects I pass are not recognized as COM objects.
An example:
In C#, the 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 = ost.Run("GetTestClass");
What I get (`obj`) is of type `System.__ComObject`. When I pass it to my
perl/PerlNET assembly and try to call method `Xyz()` in perl I get the
following (runtime) exception:
Can't locate public method Xyz() for System.__ComObject
If, however, I do more or less the same thing in perl, it works. (In the
following case, passing only the contents of my .vbs file as parameter.)
I can even use the script control :
sub UseScriptControl {
my ($self, $text, $) = @_;
my $script = Win32::OLE->new('ScriptControl');
$script->{Language} = 'VBScript';
$script->AddCode($text);
my $obj = $script->Run('GetTestClass');
$obj->Xyz();
}
Now, calling `Xyz()` on `obj` works without any problems.
In both cases I use
use strict;
use Win32;
use Win32::OLE::Variant;
Now I'm trying to figure out what could cause this problem - and if I can
solve it or if it is an issue related with the wrapping done by PerlNET.
Or if I can maybe extract some information of the __ComObject for it to be
identified correctly as COM object.
I have to add that I posted on the PDK discussion site too (but didn't get
any response yet): http://community.activestate.com/node/18247
I would greatly appreciate any help - or advise on where to look further.
mihe
_______________________________________________
Perl-Win32-Users mailing list
Perl...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs