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?

2
  • Are you sure you have correct sample pasted: differnet names GetGuid and GetGuid2 used in C# and perl portions... Commented Jan 14, 2013 at 23:12
  • It was a typo error.. I fixed it. Commented Jan 15, 2013 at 17:21

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Hi Paul, We need to get GUID object so that We can assign the GUID to another object's property. If converting to string is the only option we have got, then we will go in that route. But Exploring if there any we can expose GUID in COM Layer.
I know exactly what you are saying, because I needed to do the same thing. This is the approach I ended up having to take.
Thanks Paul for your comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.