cancel
Showing results for 
Search instead for 
Did you mean: 

Returning a structure from a call to a .NET COM wrapped dll

Former Member
0 Kudos

I've used COM wrapped ,NET dlls a lot, but up until now I've only returned simple datatypes like string and boolean. I now would like to return a class / structure, something like:

Class ConnectionInfo

   Boolean IsConnected

   String URL

ConnectionInfo IsConnected

{

  .

  .

  return connectionInfo

}

Powerbuilder code is currently something like this:

   str_sharepoint_site lstr_site

   lany = iole_xml.IsConnected()  <-- This works as I put a bunch of MessageBox.Shows in the C# code and it gets all the way to the end of the call

   lstr_site = lany   <-- Crashes here saying "Cannot convert oleobject in Any variable to str_sharepoint"

str_sharepoint is a boolean and a string

However, due to old age, long working hours, and a fear of early onset dementia I'm drawing a blank on to get the result from the call in Powerbuilder into a structure. I can get it into an OLEObject or an ANY variable, but can't think what to do with it then.

Any help much appreciated!

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Okay I seem to have solved it. It doesn't seem a very nice solution to me, but it works at least.

So I retrieve the COM method into an OLEObject I them put each property into the desired structure like so:

   ltr_sharepoint_site lstr_site

   OLEOBject lole

   lole = CREATE OLEObject

   lole = iole_xml.DoStuff()

   // Extract the results from the OLEObject into my structure

   lstr_site.sb_is_connected = lole.IsConnected

   lstr_site.ss_url = lole.URL

It requires the PB programmer to know the names of the properties in the C# code which is a shame, it would be nice to just assign like so lstr_site = iole_xml.DoStuff() but I can live with it

Answers (1)

Answers (1)

Former Member
0 Kudos

This conversation is rather long winded but might be of help

Former Member
0 Kudos

Thanks Lars, I shall read it right now!

Former Member
0 Kudos

Okay read that, but I don't think it really applies here. Just to be clear I am not calling a web service, just a straightforward C# dll that has been COM wrapped. So there's no need for passing XML or encoding in Base64. I suspect I am missing something really simple as I'm not trying to do anything particularly complicated.