C#dll注册带有regasm警告RA0000

时间:2016-09-07 08:56:23

标签: c# delphi dll regasm

我有C#dll并希望在我的delphi代码中使用它,之前必须使用regasm注册dll。我一直试图注册这个dll,但不断地低于警告 -

Microsoft Windows [Version 6.1.7601] 版权所有(c)2009 Microsoft Corporation。保留所有权利。

C:\Windows\Microsoft.NET\Framework\v4.0.30319>regasm c:\debug\modbusdll.dll
Microsoft (R) .NET Framework Assembly Registration Utility 4.0.30319.1
Copyright (C) Microsoft Corporation 1998-2004.  All rights reserved.

RegAsm : warning RA0000 : No types were registered


C:\Windows\Microsoft.NET\Framework\v4.0.30319>

在互联网上,我发现COMVisible在AssemblyInfo.cs中设置为true,它将解决这个问题。但它已经设置为true,但我仍然遇到这个问题。

C#代码如下 -

命名空间ModbusDLL {     //// {0E32E465-79A4-4251-AF02-FEBE05198F76}

[Guid("0E32E465-79A4-4251-AF02-FEBE05198F76")]
public interface IModbus
{
    bool setABC(int a);//{GUID:f7f14b6f-e8da-4562-baf7-aa6846861f66}
    byte[] getDiscreteInput(ushort id, byte unit, ushort startaddress, ushort numinputs);//{GUID:f7f14b6f-e8da-4562-baf7-aa6846861f67}
    byte[] getInputRegister(ushort id, byte unit, ushort startaddress, ushort numinputs);//{GUID:f7f14b6f-e8da-4562-baf7-aa6846861f68}
    byte[] getHoldingRegister(ushort id, byte unit, ushort startaddress, ushort numinputs);//{GUID:f7f14b6f-e8da-4562-baf7-aa6846861f69}
}
 [Guid("0E32E465-79A4-4251-AF02-FEBE05198F77")]
public class ModbusImplementor:IModbus
{
     ModbusTcpClient m=null;
     public ModbusImplementor()
     {
         //m = new ModbusTcpClient(ip, port);
     }

     /*public ModbusImplementor(string ip, ushort port)
     {
         m = new ModbusTcpClient(ip, port);
     }*/
    public bool setABC(int a)
    {
        int A = a;
        return true;
    }

    public byte[] getDiscreteInput(ushort id, byte unit, ushort startaddress, ushort numinputs)
    {
        //2,
        byte[] values =new byte[15]; 
        m.ReadDiscreteInputs(id, unit, startaddress, numinputs, ref values);
        return values;
    }
    public byte[] getInputRegister(ushort id, byte unit, ushort startaddress, ushort numinputs)
    {
        byte[] values = new byte[15]; 
        m.ReadInputRegister(id, unit, startaddress, numinputs, ref values);
        return values;
    }

    public byte[] getHoldingRegister(ushort id, byte unit, ushort startaddress, ushort numinputs)
    {
        byte[] values = new byte[15]; 
        m.ReadHoldingRegister(id, unit, startaddress, numinputs, ref values);
        return values;
    }

    ~ ModbusImplementor()
    {
        m.Disconnect();
        m.Dispose();
    }


}

}

的AssemblyInfo.cs -

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ModbusDLL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("ModbusDLL")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f7f14b6f-e8da-4562-baf7-aa6846861f66")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 个答案:

没有答案