Salesforce

Method that returns .NET object fails when calling method to resolve parameter

« Go Back

Information

 
TitleMethod that returns .NET object fails when calling method to resolve parameter
URL Name000047463
Article Number000167663
EnvironmentProduct: OpenEdge
Version: 10.2x, 11.0x, 11.1x, 11.2x, 11.3.0, 11.3.1, 11.3.2, 11.3.3
OS: Windows
Other: GUI for .NET, NETUI
Question/Problem Description
Calling a method that returns a .NET hybrid object fails when one of the parameter values passed to the method is a method or function call.

When calling a .NET method to instantiate a .NET component, and the second parameter of the method is a string, the component doesn't get correctly instantiated if the string in the second parameter comes from a User Defined Function or OOABL Method.
 
Steps to Reproduce
Clarifying Information
/* test.p */
FUNCTION GetProviderNPI RETURNS CHARACTER ( ):
  RETURN "something".
END FUNCTION.

/* DotNetUserClass is a class in ProgressTestClass.DLL */
DEFINE VARIABLE dotNetuserClass AS ProgressTestClass.DotNetUserClass NO-UNDO. 

dotNetuserClass =
  NEW ProgressTestClass.DotNetUserClass(HelperClass:GetDotNetTestClass(), GetProviderNPI()).

/* HelperClass.cls */
CLASS HelperClass ABSTRACT:
  METHOD PUBLIC STATIC ProgressTestClass.DotNetClass GetDotNetTestClass( ):
    DEFINE VARIABLE testClass AS ProgressTestClass.DotNetClass NO-UNDO.

    testClass = NEW ProgressTestClass.DotNetClass().
    testClass:SomeProperty = 'abc'.
   
    RETURN testClass.
  END METHOD.
END CLASS.

 
Error Message
Defect NumberDefect PSC00292517
Enhancement Number
Cause
A null object reference (unknown), is passed to .NET for garbage collection and is not a valid object when referred to. 
 
Resolution
Upgrade to OpenEdge 11.3.3, 11.4.0 or later. Where objects are not deleted prematurely.

This fix consequently causes a memory leak when objects are not garbage collected by .NET. It is advisable to upgrade to OpenEdge 11.7.4 where a new routine frees references to objects allowing them to get garbage collected in .NET  For further information refer to Article:
Workaround
Consider using a Variable:
/* test.p */
FUNCTION GetProviderNPI RETURNS CHARACTER ( ):
  RETURN "something".
END FUNCTION.

/* DotNetUserClass is a class in ProgressTestClass.DLL */
DEFINE VARIABLE dotNetuserClass AS ProgressTestClass.DotNetUserClass NO-UNDO. 

DEFINE VARIABLE   cProviderNPI AS CHARACTER NO-UNDO.

cProviderNPI = GetProviderNPI().
dotNetuserClass = 
  NEW ProgressTestClass.DotNetUserClass(HelperClass:GetDotNetTestClass(), cProviderNPI).

/* HelperClass.cls */
CLASS HelperClass ABSTRACT:
  METHOD PUBLIC STATIC ProgressTestClass.DotNetClass GetDotNetTestClass( ):
    DEFINE VARIABLE testClass AS ProgressTestClass.DotNetClass NO-UNDO.

    testClass = NEW ProgressTestClass.DotNetClass().
    testClass:SomeProperty = 'abc'.
    
    RETURN testClass.
  END METHOD.
END CLASS.
Notes
Keyword Phrase
Last Modified Date11/20/2020 7:05 AM

Powered by