How to use my home-made .NET C# DLL from within Progress

pierremans

New Member
(Progress V9.1D09)
(.NET Framework 2.0.50727)

Hi,

I am trying to build a dll from MS Visual Studio and use that from within my Progress app.

Simple source in C#:
using System;
//using System.Collections.Generic;
using System.Text;

namespace pvbb
{
public class Class1
{
static public String pEcho (String txt) {
return txt + "\n" + txt + " " + txt;
}
}
}
Now the question is: how can I use pEcho from within Progress?!? :confused:

I tried this:
PROCEDURE pecho EXTERNAL "h:\ff\pvbb.dll":
DEFINE INPUT PARAMETER cTxt AS CHARACTER NO-UNDO.
DEFINE RETURN PARAMETER cReturn AS CHARACTER NO-UNDO.
END.


DEFINE VARIABLE c AS CHARACTER NO-UNDO.
RUN pEcho (INPUT "this is a test", OUTPUT c).
But that gives me an error in finding the correct entrypoint. Even with CDECL.

Can someone tell me how to make this work?

TIA

Pieter Brouwer
 
Got this answer form dotnet@peg.com:

Hi Pieter,

It is possible to use .NET types from COM by following these guidelines:
- Create managed type in the usual way.
- Use TlbExp to create COM type library.
- Register the assembly with RegAsm.
- Reference the type library as necessary.
- Use the types as normal COM types.

I barely develop in .NET (so don't ask me too much), but here is an
example called Class1.cs:
--------------
using System;
using System.Runtime.InteropServices;

namespace HelloWorld
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Class1
{
public string DisplayHello()
{
string Disp = "Hello World";
return Disp;
}
}
}
--------------

Do the the following:
1. Open a Proenv command prompt (type "prompt" to see path).
2. Execute <VS2003_InstallDir>\Common7\Tools\vsvars32.bat
3. Compile the class: csc /t:library /out:%DLC%\bin\Class1.dll
Class1.cs
4. Register the DLL: regasm /tlb %DLC%\bin\Class1.dll
5. Run the following code from Progress:

--------------
DEFINE VARIABLE chHello AS COM-HANDLE.

CREATE "HelloWorld.Class1" chHello.

MESSAGE chHello:DisplayHello
VIEW-AS ALERT-BOX INFO BUTTONS OK.

RELEASE OBJECT chHello.
--------------

You can use the Progress COM Object Viewer (%DLC%\bin\proobjvvw.exe) in
order to see all the methods and properties of the DLL by opening it's
corresponding TLB file. Also if you do not want to put the DLL in your
Progress Bin directory, then I believe you should put it in the .NET
GAC.

Hth,

- Donicello
 
Back
Top