How to call vb.net dll, passing multiple inputs and returnin

Posted by tromba99 on 17-Jul-2012 08:06

I am new to OpenEdge ABL and we use it as part of our Epicor ERP system.
I need a good step-by-step explanation or some clear examples of how to invoke in a ".p" program a vb.net dll that I have made which involves passing a few inputs and returning a few outputs.
If I were using this dll in a VB.net program, my call basically looks like this:

Imports GetPrice

Dim PriceInfoRec As PriceInfo = GetPrice.PriceInfo.GetNCSPrice(PriceYear, Part, OrderQty, PriceList, InvLang)

Where PriceInfo is a class which includes 4 properties. I need these 4 properties returned in the ".p" program.

Any help would be greatly appreciated as this is the last stubbling block in a big project for me.

All Replies

Posted by Admin on 17-Jul-2012 09:51

Which version of Progress?

GUI or TTY?

Posted by tromba99 on 17-Jul-2012 10:06

Which version of Progress?

The version is OpenEdge 10.2a and service Pack 3 has been applied.
GUI or TTY?
GUI
Posted by Admin on 17-Jul-2012 10:21

Then check the "GUI for .NET Developers Guide". That will tell you how to use .NET Assemblies from the ABL GUI client.

Although officially you should be on 10.2B02 to use non visual .NET components. But technically 10.2A should support it.

Posted by tromba99 on 17-Jul-2012 10:35
I have probably caused you some confusion with my last answer to your question about GUI or TTY.
We are not actually using any OpenEdge Development Tools at all to write the little bit of progress code we use for Epicor.
We have (with the help of consultants) written a few text based ".p" programs in what they used to call 4GL Progress to interact with our Product Configurators in Epicor.
Our consultant provided us with a PDF of a programming guide for OpenEdge 10 called "OpenEdge Development: Progress 4GL Reference", but it is very unclear and hard to follow.
I hope this clarifies the situation some and I apologize for the confusion my last answer caused.
Posted by Admin on 17-Jul-2012 10:46

Where is that .p being executed?

On an AppServer, in _progress or prowin32.exe?

Posted by tromba99 on 17-Jul-2012 11:01
I know we are running an AppServer and on it I see many instances of a process call "_proapsv.exe" running.
Does this help?
Sorry if I don't know the exact answers as others in my company were involved in the environment and architecture of this new system.
If this is not a helpful response, I will consult with our DB and system administrators when I have the opportunity.
Thank you very much, BTW, for your prompt and direct responses.
Posted by Admin on 17-Jul-2012 11:11

For the Windows AppServer in 10.2A you need to turn your VB Assembly into a COM-Interop Assembly.

The 10.2A AppServer can only execute regular Windows DLLs and COM-Automation Servers.

Posted by Roberta Miller on 17-Jul-2012 11:45

Hi Roy,

The name "Progress 4GL Reference" tells me that you have an older version of the manual (OpenEdge 10.1A or earlier). In OE 10.1B Progress changed the name of the language to "ABL" (Advanced Business Language) to reflect it's evolution, and therefore changed the name of the manual to "ABL Reference". OpenEdge didn't support .NET until 10.2A, so the information you need about how to call .NET methods isn't in the PDF you have.

You can get all the OpenEdge 10.2A documentation here on Progress Communities at . The ABL Reference is in the ABL section. It is a syntax reference, not a tutorial, but it does include all the changes to the language needed to work with .NET classes.

For a better introduction to using .NET classes from ABL, look at "GUI for .NET Programming" in the "OpenEdge GUI for .NET" section of the documentation page. This is the book that Mike mentioned earlier in this thread. Chapter 1, "Accessing and Managing .NET Classes from ABL", should have the information you need.

Just to get you started, your VB code would look something like this in ABL:

USING GetPrice

 

DEFINE VARIABLE PriceInfoRec AS PriceInfo NO-UNDO.

 

PriceInfo = GetPrice.PriceInfo.GetNCSPrice(PriceYear, Part, OrderQty, PriceList, InvLang).

This assumes that the other variables are defined, your DLL is in the right place, etc. You can find information on deploying applications with .NET classes in the "Managing ABL Applications" book in the Deployment section of the doc page; you may also want to look at the instructions for installing the sample code in the preface of "GUI for .NET Programming".

As Mike also mentioned, in OpenEdge 10.2A you cannot call .NET methods from a non-GUI client such as the AppServer. This is due to a software implementation of a license restriction that existed in OE 10.2A, but has since been lifted.

HTH,

Roberta

Posted by tromba99 on 17-Jul-2012 12:19
I had found the information about needing the assembly to be a "COM-Interop Assembly" and it already is.
I will take some time now to digest your responses along with Roberta's and see if I can get this to work.
Thank you for your help.
Posted by tromba99 on 17-Jul-2012 12:20
I have now downloaded the correct refernce manual and I will take some time to digest it and your response.
Hopefully I can get it to work now.
Thank you very much for such a prompt and complete answer.
Posted by tromba99 on 18-Jul-2012 13:14
After looking over some of this documentation I have come across and issue:
The documentation only talks about selecting the dll that I want to use from a GUI screen in the development environment much like I would do when selecting a reference in VB.net.
As I stated in an earlier post, we do not actually use the OpenEdge Development Studio.  The ".p" programs we use are just called from a "run" command inside of the Epicor configurators.  We have not had need to do any compiling of code.
Will I be able to make my dll available to my ".p" program without the development environment?
If so, how should I deploy that dll to accomplish that?
Posted by Admin on 18-Jul-2012 13:21

Will I be able to make my dll available to my ".p" program without the development environment?

Yes.

If so, how should I deploy that dll to accomplish that?

It needs to be registered using regsvr32 as an automation server - not as an Active X control.

Then read up about using automation servers using COM-HANDLE variables. There's a reference entry for the "CREATE automation object statement ".

DEFINE VARAIBLE chHandle AS COM-HANDLE NO-UNDO .

CREATE yourvbdotnet.classname chHandle.

chHandle:YourMethodHere () .

Posted by tromba99 on 19-Jul-2012 12:18
I have been able to register my .net dll using regasm.exe.
It now shows up in the registry of the server I am testing this all on.
I started out using the code snippet in my ".p" program that you supplied in your last post.

USING GetPrice

DEFINE VARIABLE PriceInfoRec AS PriceInfo NO-UNDO.

PriceInfo = GetPrice.PriceInfo.GetNCSPrice(PriceYear, Part, OrderQty, PriceList, InvLang).

After getting some "4gl stop errors" and consulting the documentation I made some adjustments leaving me with this code:
USING "GetPrice.*".
DEFINE VARIABLE PriceInfoRec AS "GetPrice.PriceInfo" NO-UNDO.
PriceInfoRec = GetPrice.PriceInfo.GetNCSPrice(PriceYear, Part, OrderQty, PriceList, InvLang).
Now I am getting an error that says:
"Invalid datatype specified: GetPrice.PriceInfo. Specify a datatype such as 'character' or the name of a class."
I have tried "PriceInfo" with and without quotes, "GetPrice.PriceInfo" with and without quotes, "GetPrice+PriceInfo" with and without quotes and I get the same error.
Any suggestions as to what I am doing wrong?
Posted by Peter Judge on 19-Jul-2012 12:31

Firstly, remove the quotes.

Then change the following line so that the method call is preceded by a colon (, not point (.)

PriceInfo = GetPrice.PriceInfo.GetNCSPrice(PriceYear, Part, OrderQty, PriceList, InvLang).

-- peter

Posted by tromba99 on 20-Jul-2012 07:29
Peter,
I have removed the quotes.
I was unclear as to what you meant about the colon so I tried a number of combinations to no avail.
This is my code currently:
USING GetPrice.*.
DEFINE VARIABLE PriceInfoRec AS GetPrice.PriceInfo NO-UNDO.
PriceInfoRec = GetPrice:PriceInfo:GetNCSPrice(PriceYear, Part, OrderQty, PriceList, InvLang).
I am still getting the following error on the variable definition line:
"Invalid datatype specified: GetPrice.PriceInfo. Specify a datatype such as 'character' or the name of a class."
To me, nothing I can change in code after that line would have any effect on that error.
It is that line(at this moment) that needs to be changed in some way to get the variable defined properly.
I need to make some progess(no pun intended) on this issue soon or I have to go a whole different way in this project.
Thanks for your help.
Posted by Peter Judge on 23-Jul-2012 08:54

tromba99 wrote:

Peter,
I have removed the quotes.
I was unclear as to what you meant about the colon so I tried a number of combinations to no avail.
This is my code currently:
USING GetPrice.*.
DEFINE VARIABLE PriceInfoRec AS GetPrice.PriceInfo NO-UNDO.
PriceInfoRec = GetPrice:PriceInfo:GetNCSPrice(PriceYear, Part, OrderQty, PriceList, InvLang).
I am still getting the following error on the variable definition line:
"Invalid datatype specified: GetPrice.PriceInfo. Specify a datatype such as 'character' or the name of a class."
To me, nothing I can change in code after that line would have any effect on that error.
It is that line(at this moment) that needs to be changed in some way to get the variable defined properly.
I need to make some progess(no pun intended) on this issue soon or I have to go a whole different way in this project.
Thanks for your help.

Is PriceInfo a class?  Does it appear in the propath? Syntactically, that line should compile. If it's a DLL, is it in the GAC, or is it in the directory referred to by the -assemblies parameter? Is there a reference to the DLL in the assemblies.xml file? If not, you should add it. You can do so via the "Add Assembly References" context menu on the project's Reference Assemblies node.

Also, periods/dots are for package separation. Colons are for class/type and method/property separation. So I would guess that your code would need to look something like the below.

USING GetPrice.*.
DEFINE VARIABLE PriceInfoRec AS GetPrice.PriceInfo NO-UNDO.
PriceInfoRec = GetPrice.PriceInfo:GetNCSPrice(PriceYear, Part, OrderQty, PriceList, InvLang).

The OO ABL  doc is at http://documentation.progress.com/output/OpenEdge111/pdfs/dvoop/dvoop.pdf  which may help for these kinds of questions.

-- peter

This thread is closed