Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 无法连接到ABB Freeline OPC服务器[不支持此类接口(HRESULT的异常:0x80004002(E_NOINTERFACE))]_.net_Windows_Com_Dcom_Opc - Fatal编程技术网

.net 无法连接到ABB Freeline OPC服务器[不支持此类接口(HRESULT的异常:0x80004002(E_NOINTERFACE))]

.net 无法连接到ABB Freeline OPC服务器[不支持此类接口(HRESULT的异常:0x80004002(E_NOINTERFACE))],.net,windows,com,dcom,opc,.net,Windows,Com,Dcom,Opc,我的OPC客户端应用程序在使用OPC NET API 2.00时出现问题,因此当我想连接到ABB Freedor OPC Server时,调用OPC.Server.connect(OPC.ConnectData)方法时会抛出异常 例外情况: 无法将“System.\u ComObject”类型的COM对象强制转换为 接口类型“OpcRcw.Comn.IOPCServerList2”。此操作失败 因为接口的COM组件上的QueryInterface调用 由于以下原因,IID“{9DD0B56C-A

我的OPC客户端应用程序在使用
OPC NET API 2.00
时出现问题,因此当我想连接到ABB Freedor OPC Server时,调用
OPC.Server.connect(OPC.ConnectData)
方法时会抛出异常

例外情况:

无法将“System.\u ComObject”类型的COM对象强制转换为 接口类型“OpcRcw.Comn.IOPCServerList2”。此操作失败 因为接口的COM组件上的QueryInterface调用 由于以下原因,IID“{9DD0B56C-AD9E-43EE-8305-487F3188BF7A}”失败: 以下错误:不支持此类接口(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);
    }
}

这里的E_NOINTERFACE是一个通用的COM错误(对于指示真正的问题没有那么大用处)

检查:

  • 在客户端上:“OPC核心组件可再发行”和RCWs mergemodule是否已安装

  • 在客户端:防火墙设置

  • 在服务器上:abb opc服务器的dcom设置是否正确

只要查看IOPCServerList2的源代码,我的IOPCServerList2与您的版本不同。 我猜您尝试使用为OPC DA 1.0设计的旧合并模块/api(这是一个非常古老的开放式OPC标准),大多数OPC服务器都希望使用OPC DA 2.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 );
    }
}

IOPCCServerList2是OPCEnum服务的一部分,而不是服务器本身的一部分

如果从远程连接,则应用程序正在访问与服务器在同一台计算机上运行的OPCEnum服务

IOPCCServerList2是IOPCCServerList的新版本,最有可能的原因是与ABB Freeline一起安装的OPCEnum服务版本太旧


您可以通过安装从提供的最新OPC核心组件来更新OPCEnum服务。

是的,当连接到其他OPC服务器品牌(如横河或Matrikon)时,所有这些组件都能正常工作,但不适用于ABB OPC服务器。您是否有一些OPC测试客户端来尝试连接?是,Matrikon和其他一些商业opc客户端可以连接和读取数据,但.Net API无法连接。请检查您的opc.Net API和合并模块版本。您可能需要使用OPC DA 2.0版本。我的OPC Net API版本是2.0,核心组件版本是3.0,OPC DA版本是1.1是的,这是我的问题的重点,但对于您的回答,我们无法在OPC服务器上安装或更新任何软件,我们有工厂限制来执行此操作。然后您需要避免使用OPCEnum或修改.NET API,以便它使用IOPCServerList而不是IOPCServerList2。您可以通过使用服务器的CLSID而不是ProgID来避免它。但是我对.NET API不是100%肯定。感谢Jouni Aro,为了忽略副作用,
IOPCServerList2
是一个内部接口,我不能将其更改为使用
IOPCServerList
,我们解决了将OPC API从.NET API更改为另一个基于Python的API的问题。