Guid Object in Function Return in COM Interface

2

I have a COM Interface which has function signature as mentioned below:

Guid GetGuid2()

It is implemented in a class:

    public Guid GetGuid2()
    {
      return Guid.NewGuid();
    }

Then this function needs to be used by Perl.

    my $dotNetLib = 'MyCOMDLL';
    my $server = Win32::OLE->new($dotNetLib) || die "Unable to launch server\n";
    my $guid = $server->GetGuid2();

But I am getting this error:

Win32::OLE(0.1601) error 0x80020005: "Type mismatch" at Playground.pl

Is it possible for us to return GUID Object in COM Layer?

c#
.net
perl
com
asked on Stack Overflow Jan 14, 2013 by K2M • edited Jun 29, 2019 by Cœur

1 Answer

2

when you need to return a GUID from COM via .NET you need to convert it to a Byte[] or a String and then rebuild it to a guid on the other side or perform string comparision, as a GUID isn't a COM Compatible type.

answered on Stack Overflow Jan 15, 2013 by Paul Farry

User contributions licensed under CC BY-SA 3.0