VC6 调用C#DLL文件,采用注册Com方法,但是遇到C#中的类无法使用

逆鳞92 2016-03-21 09:24:10
VC6 调用C#写的DLL文件,采用注册Com方法,但是遇到C#中的类无法使用,
需要使用GetCharger()方法,但是返回类型是一个class ,在C#中数据都封装在类的字段中,使用属性get 或set,不知道在C++中怎么使用这些数据,

public Charger GetCharger(uint address)
{
if (address >= 1 && address <= 16)
{
return chargers[address - 1];
}
else
{
throw new EVPException("Charger with address " + address + " does not exist.");
}
}



public class Charger
{
private float inputCurrent = 0;
private float outputCurrent = 0;
private float outputVoltage = 0;
private uint availablePower = 0;
private sbyte primaryTemp = 0;
private sbyte secondaryTemp = 0;
private sbyte trafoTemp = 0;
private uint inputVoltage = 0;
private byte inputFrequency = 0;
private SystemState systemState = SystemState.SystemState_Idle;
private string[] alarmDescription = new string[32];
private bool[] alarmSetting = new bool[32];
private SelfTest selfTest = new SelfTest();
private bool isPresent = false;

private uint address = 0;
private uint baseCanId = 0;
private DateTime lastStatusTime = new DateTime(0);
private List<ProtocolMessage> sequenceList = new List<ProtocolMessage>();
private DelegateSendMessage SendMessage;
private Configuration configuration = new Configuration();
private Diagnostics diagnostics = new Diagnostics();
...全文
1014 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
okkk 2017-02-12
  • 打赏
  • 举报
回复
引用 1 楼 hdt 的回复:
try [ComVisible] public class Charger{ ........... }
正解
threenewbee 2017-02-09
  • 打赏
  • 举报
回复
get/set可以用 get_属性名 作为函数名访问
真相重于对错 2017-02-08
  • 打赏
  • 举报
回复
try [ComVisible] public class Charger{ ........... }

7,540

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 VC.NET
社区管理员
  • VC.NET社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧