I have C# dll and want to use it in my delphi code, before that the dll must be registered with regasm. I have been trying to register this dll but constatntly getting below warning-
Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved.
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>
On the internet I found that COMVisible set to be true in AssemblyInfo.cs, and it will solve this problem.But it was already set to true and still I am getting this problem.
C# code is as follows-
namespace 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")]