3

I'm wondering how I can create a Com-Object from my own C# DLL.

I made the following Class in C#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace ProgressNet
{
    [Guid("a9b1e34d-3ea3-4e91-a77a-5bcb25875485")]
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [ComVisible(true)]
    [ProgId("ProgressNet.Server")]
    public class NetServer
    {
        public NetServer() {}

        [DispId(1)]
        public string GetString()
        {
            return "Some String";
        }
    }
}

In Properties I checked Register for COM Interop.

Then I registered the DLL with regasm.

regasm G:\ProgressTestApp\ProgressNet.dll /tlb:G:\ProgressTestApp\ProgressNet.tlb /codebase

Then I tried in Progress 4GL this Code:

DEFINE VARIABLE NetServer AS COM-HANDLE.
CREATE "ProgressNet.NetServer" NetServer.  
MESSAGE NetServer:GetString().

But then I get "The automation server for ProgressNet.NetServer is not registered properly"..

Any Suggestions? :)

RaphaelH
  • 2,144
  • 2
  • 30
  • 43
  • The error message is pretty explicit. The description of how you used regasm is not. – Hans Passant Jul 27 '12 at 12:49
  • regasm G:\ProgressTestApp\ProgressNet.dll /tlb:G:\ProgressTestApp\ProgressNet.tlb – RaphaelH Jul 27 '12 at 14:13
  • Add the /codebase option so you don't have to put the assembly in the GAC. – Hans Passant Jul 27 '12 at 16:17
  • Hi man, How did you work for this code at the end? – John May 15 '14 at 18:55
  • @John I don't understand your question. What do you want to know? :) – RaphaelH May 16 '14 at 04:21
  • How did you run the code?, I use Progress 9.1e, I made a DLL with C # code as following your model. When you import the DLL in "Progress" as COM shows me the functions created in the DLL which receive strings to call these functions I get an error when compiling my. P – John May 16 '14 at 13:44
  • @John Compile DLL, regasm, and then I ran the code inside a Procedure Window from the AppBuilder, we're running on Progress 10.1C – RaphaelH May 21 '14 at 08:03

2 Answers2

1

IN case anyone is still reading this, the answer turns out to be pretty simple: The following line is wrong.

MESSAGE NetServer::GetString().

It should be

MESSAGE NetServer:GetString().
Rick C
  • 56
  • 5
1

The error is in the create com-handle statement. It should be create "ProgressNet.Server" NetServer. and not "ProgressNet.NetServer" as specified by the ProgId call.

I registered the DLL with regasm as you mentioned and used the code below to test and it worked fine.

def var ch as com-handle no-undo.

create "ProgressNet.Server" ch.

MESSAGE ch:GetString()
    VIEW-AS ALERT-BOX INFO BUTTONS OK.