Error accessing object array from external class library

瀏覽次數:7 次
跳到第一則未讀訊息

Jade Clements

未讀,
2023年2月2日 晚上9:26:062023/2/2
收件者:openroa...@googlegroups.com

Hello OR world,

 

Posting this for a colleague.

 

I've got a C# library which has a method which returns an array of objects CrystalReportParameter below:

  CrystalReportParameter[] DMTempMethod(string paramName);

In the OR class browser (OR 11.2) it shows my method as returning an array as well as showing my object class. However, when trying to assign the array of objects, on calling the method in OR, I get the following error:

E_OM0029 Converion error during return.

 

A data conversion error occurred while returning a value from a procedure or method invocation. The return value could not be converted to the type expected by the calling object.

 

my OR declaration code is:

  reportObj = reportLibrary!service;  

  reportParams = ARRAY OF reportLibrary!crystalreportparameter; 

reportLibrary is the external class library, service is the class holding the methods and crystalreportparameter is the class that has been returned.

 

my method calling code is:

reportParams = reportObj.dmtempmethod('repparm');

 

I've got another method which just returns a crystalreportparameter object itself and have no issues accessing the object returned.

I've tried a simpler method returning an array of strings:

       string[] stringArrayMethod(string paramName); //C#

       reportParamss = ARRAY OF StringObject;  //OR

       reportParamss = reportObj.stringarraymethod('repparms'); //OR

 

I get the same error as above.

Therefore, does OR not allow external libraries to return arrays or have I incorrectly defined or called my external library method?

 

Regards,

Jade

 

 

Jade Clements
Developer
P
M
Fusion5
Level 27, 570 Bourke Street, Melbourne, 3000, Australia
Fusion5
This email and any attachments are confidential and intended exclusively for the person to whom the email is addressed. Please see our Privacy Policy

ID0EC

Bodo Bergmann

未讀,
2023年2月3日 凌晨4:42:172023/2/3
收件者:openroa...@googlegroups.com

Hi Jade,

 

The same question has already been asked by David Menz in the OpenROAD Community forum:

https://communities.actian.com/s/question/0D54y00008K1rwSCAR/error-accessing-object-array-from-external-class-library

I have replied there, here is a copy of it:

You cannot map a C# array (.NET) directly to an OpenROAD Array.
As OpenROAD supports COM, there must be a COM interface for your .NET library (which has to be made "COM-visible").
How is the method defined in the according COM TypeLibrary?
Check using the OLE/COM Viewer (oleview.exe) coming with Visual Studio. 

What OpenROAD could actually do is to use a Collection of external objects,
see https://docs.actian.com/openroad/11.2/index.html#page/Programming/How_You_Can_Use_Collections_with_External_Classe.htm

 Try some declaration like this:

reportParams = Collection OF reportLibrary!crystalreportparameter;

HTH.
Best regards,
Bodo

Bodo Bergmann
Engineering Architect | OpenROAD Engineering

Actian, A Division of HCLSoftware 


GESELLSCHAFTSANGABEN: Actian Germany GmbH | Sitz der Gesellschaft: Halenreie 42, 22359 Hamburg | Geschäftsführung: Stephen Padgett, Marc Monahan | Handelsregister: Amtsgericht Hamburg | HRB 135991 | USt-IdNr: DE252449897

--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/SY6PR01MB7351728A374FCEDEDC6ADD989DD79%40SY6PR01MB7351.ausprd01.prod.outlook.com.

回覆所有人
回覆作者
轉寄
0 則新訊息