Hi Miriam,

I wish I could be more helpful, but unfortunately most of the PerlNET
expertise here at ActiveState was with my predecessor, and I am still
coming up to speed on it. You are probably already aware of it, but I would
point you at this old book on PerlNET that may be of some help:
http://amzn.com/0130652067

If you could put together a simple test case that demonstrates the problem
you're having, I would be happy to take a look at it.

---
Andy Grundman
Lead Perl Language Developer, ActiveState
an...@activestate.com

On Thu, Oct 22, 2015 at 5:51 PM, Miriam Heinz <miriam.he...@itk-austria.com>
wrote:

> 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-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
>
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to