从自己的C#Dll进行中4GL创建COM对象 [英] Create COM-Object from own C# Dll in Progress 4GL

查看:92
本文介绍了从自己的C#Dll进行中4GL创建COM对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何通过自己的C#DLL创建Com-Object。



我在C#中创建了以下类:

 使用系统; 
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用System.Runtime.InteropServices;

命名空间ProgressNet
{
[Guid( a9b1e34d-3ea3-4e91-a77a-5bcb25875485)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ComVisible(true)]
[ProgId( ProgressNet.Server)]
公共类NetServer
{
public NetServer(){}

[DispId(1)]
公共字符串GetString()
{
返回某些字符串;
}
}
}

在我检查过的属性中注册COM Interop。



然后我用重生注册了DLL。

  regasm G:\ProgressTestApp\ProgressNet.dll /tlb:G:\ProgressTestApp\ProgressNet.tlb/代码库

然后我在进行4GL的此代码中进行尝试:

 定义可变NetServer作为COM-HANDLE。 
创建 ProgressNet.NetServer NetServer。
消息NetServer:GetString()。

但是我得到 ProgressNet.NetServer的自动化服务器未正确注册。 p>

有什么建议吗? :)

解决方案

万一有人还在读这篇文章,答案很简单:以下一行是错误的。

  MESSAGE NetServer :: GetString()。 

应该是

 消息NetServer:GetString()。 


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? :)

解决方案

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().

这篇关于从自己的C#Dll进行中4GL创建COM对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆