我从a.dll发送一个值(attrname [5] =“WRM Version”;)来自SendAgentInfo() 它在sp.dll中作为WrmVersion.From接收到这里我将这些值发送到位于data.dll的接口(IResourcePolicy)。但问题是数据 没有获得接口'IResourcePolicy',如果在接口中收到它,它应该在UI中的LISTVIEW中显示(UI.dll中的ResourcePolicySystemsControl.cs0) 我所做的编码如下:
code in a.dll
public void SendAgentInfo()
{
string[] attrname = new string[6];
string[] attrval = new string[6];
attrname[5] = "WRM Version";
.
.
attrval[5] = Registry.GetValue(@"HKEY_LOCAL_MACHINE\Software\syscon\Single Point Operations Windows Resource Monitor", "CurrentVersion", "0").ToString();
}
code in sp.dll
string wrmVersionSPURT = this_event.variableData[5].atr_value;
.
.
IResourcePolicy irp = (IResourcePolicy)
.
.
irp.WrmVersion = wrmVersionSPURT;
.
.
code data.dll
public interface IResourcePolicy
{
string WrmVersion
{
get;
set;
}
}
code UI.dll
public new IResourcePolicy Data
{
get
{
return (IResourcePolicy)base.Data;
}
}
.
.
protected override void OnUpdate()
{
string func = "ResourcePolicySystemsLVI.OnUpdate";
try
{
if(Data != null)
{
Text = base.Data.Name;
if(SubItems.Count == 1)
{
SubItems.Add(((IResourcePolicy)Data).ResourcePolicyEnabled.ToString());
SubItems.Add(((IResourcePolicy)Data).ResourcePolicyCurrent.ToString());
SubItems.Add(((IResourcePolicy)Data).WrmVersion.ToString());
}
else
{
SubItems[1].Text = ((IResourcePolicy)Data).ResourcePolicyEnabled.ToString();
SubItems[2].Text = ((IResourcePolicy)Data).ResourcePolicyCurrent.ToString();
}
}
base.OnUpdate();
}
答案 0 :(得分:0)
您需要有一个实现IResourcePolicy
的类,它将以某种方式分配给UI.dll中的属性Data
。注意,接口不是对象;它只描述了实现它的类所期望的接口。它不能单独使用,但必须由类实现才能使用。