在使用OPC NET API 2.00的OPC客户端应用程序中我遇到了问题,所以当我想连接到ABB自由职业者OPC服务器时,它会在调用Opc.Server.Connect(Opc.ConnectData)方法时抛出异常。
例外:
无法将类型为“System.__ComObject”的COM对象转换为接口类型'OpcRcw.Comn.IOPCServerList2‘。此操作失败,因为对IID '{9DD0B56C-AD9E-43EE-8305-487F3188BF7A}‘接口的COM组件的QueryInterface调用失败:不支持此类接口( HRESULT: 0x80004002 (E_NOINTERFACE)例外)。
可能是与IOPCServerList2接口相关的问题:
#region Assembly OpcRcw.Comn.dll, v1.10.2.0
// C:\Windows\assembly\GAC_MSIL\OpcRcw.Comn\1.10.2.0__9a40e993cbface53\OpcRcw.Comn.dll
#endregion
using System;
using System.Runtime.InteropServices;
namespace OpcRcw.Comn
{
[Guid("9DD0B56C-AD9E-43EE-8305-487F3188BF7A")]
[InterfaceType(1)]
public interface IOPCServerList2
{
void CLSIDFromProgID(string szProgId, out Guid clsid);
void EnumClassesOfCategories(int cImplemented, Guid[] rgcatidImpl, int cRequired, Guid[] rgcatidReq, out IOPCEnumGUID ppenumClsid);
void GetClassDetails(ref Guid clsid, out string ppszProgID, out string ppszUserType, out string ppszVerIndProgID);
}
}发布于 2016-06-14 09:41:09
IOPCCServerList2是OPCEnum服务的一部分,而不是服务器本身的一部分。
如果从远程连接,则应用程序将访问与服务器在同一台计算机上运行的OPCEnum服务。
IOPCCServerList2是IOPCCServerList的新版本,最有可能的是安装在OPCEnum自由职业者身上的OPCEnum服务版本太旧了。
您可以通过安装来自OPCEnum的最新OPCEnum组件来更新OPC基金会网站服务。
发布于 2016-06-13 09:40:12
这里的E_NOINTERFACE是一个通用的COM错误(对于指出真正的问题不太有用)。
检查:
只要查看一下IOPCCServerList2的源代码,我的IOPCServerList2就会有与您不同的版本。我猜您尝试使用为OPCDA1.0设计的旧的合并模块/api(这是一个非常古老和过时的OPC标准),大多数opc服务器期望OPCDA2.0客户端连接。
这是我的:
#region Assembly OpcComRcw, Version=2.0.105.1, Culture=neutral, PublicKeyToken=9a40e993cbface53
// C:\WINDOWS\assembly\GAC_MSIL\OpcComRcw\2.0.105.1__9a40e993cbface53\OpcComRcw.dll
#endregion
using System;
using System.Runtime.InteropServices;
namespace OpcRcw.Comn
{
[Guid( "9DD0B56C-AD9E-43ee-8305-487F3188BF7A" )]
[InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]
public interface IOPCServerList2
{
void CLSIDFromProgID( string szProgId, out Guid clsid );
void EnumClassesOfCategories( int cImplemented, Guid[ ] rgcatidImpl, int cRequired, Guid[ ] rgcatidReq, out IOPCEnumGUID ppenumClsid );
void GetClassDetails( ref Guid clsid, out string ppszProgID, out string ppszUserType, out string ppszVerIndProgID );
}
}https://stackoverflow.com/questions/37731462
复制相似问题