来源:https://pisquare.osisoft.com/message/13441
A failuare of generating OSIDAAuto.OPCServer
dorisliper 2011-2-17 上午2:13Dear Sir/Madam
We'd like to use OSIDAAuto.OPCServer, but an exception occurs as follows when we generate OSIDAAuto.OPCServer. "error message:the following error occurred:80040154 when obtaining the COM class factory of component including CLSID{25E4451E-DA6A...}" We think that registering COM componet is done well, because the same key exists in the registry. Please let me know if you know another reason.
Environment OS:Windows Server Enterprise SP2 (64Bit)
developing tool:Visual Studio 2008(VB.NET / 3.5SP1)
Source Code
Dim myOPCServer AS OSIDAAuto.OPCServer = new OSIDAAuto.OPCServer()
Sincerely yours, Yamaguchi
- 127 查看
- 标签: opc_da
带有 opc_da 标记的内容
-
Re: A failuare of generating OSIDAAuto.OPCServer
hanyong2011-2-17 上午5:59 (回复 dorisliper)
Hi Yamaguchi,
I guess you are trying to write an OPC client that reads data from PI Server via PI OPC DA Server? Have you tried connecting to PI OPC Server using PI OPC Client or other 3rd party OPC client from the development machine? Is the PI Server on the same machine?
-
Re: A failuare of generating OSIDAAuto.OPCServer
spilon 2011-2-17 上午8:22 (回复 hanyong)Is your application (the OPC Client) on the same machine than the PI OPC DA/HDA Server? I'm asking because it might very well be a DCOM security issue... I would kindly recommend you read the section on security and DCOM in the PI OPC DA/HDA Server manual (available on the vCampus Library, under vCampus PI Products Kit > Data Access Technologies).
-
Re: A failuare of generating OSIDAAuto.OPCServer
dorisliper 2011-2-22 下午3:02 (回复 spilon)Han san, Steve san,
Thank you so much for your answer.
The same error is displayed when the component generation is done though I set the DCOM while seeing the
taught manual.
PI Server, PI OPC Server and the program to be executed are in the same host.
The thing I was anxious when I saw the manual is below.
"It should be Windows 2000/XP.
Although there are costomers who operate with Windows2003, that is not examined formally."
Is it OK that we are testing in Windows2008(64bit)?
In the manual, there is a descripition of using PISDK in PI OPC Server,too.
Is there a condition that it's necessary to generate PI SDK before OPC server is generated?
The source code is the following.
Please teach if there is a code problem.
- Imports OSIDAAuto
- '''
- ''' Test Program
- ''' Watch Tag
- '''
- '''
- ''' +-------------+ +----------------------+ +--------------+ +-----------+
- ''' | ClsWatchOPC | -> |OSIsoft.OSIDAAuto.dll | -> | PI OPC Server| -> | PI Server |
- ''' +-------------+ +----------------------+ +--------------+ +-----------+
- '''
- Public Class ClsWatchOPC
- Protected _OPCServer As OPCServer
- Protected _OPCGroups As OPCGroups
- Protected WithEvents _OPCGroup As OPCGroup
- Protected _OPCItems As OPCItems
- Protected _OPCItem As OPCItem
- Public Const ITEM_MAX As Integer = 8
- Public ItemName(ITEM_MAX) As String
- Public HandleClient(ITEM_MAX) As Integer
- Public HandleServer(ITEM_MAX) As Integer
- Public oVal(ITEM_MAX) As Object
- Public dTime(ITEM_MAX) As Date
- Public wQuality(ITEM_MAX) As Short
- Private Sub New()
- Dim ServerHandles As Array = Nothing
- Dim Errors As Array = Nothing
- ' Create OPCServer and Connect
- Debug.WriteLine("Start : Create OPCServer")
- _OPCServer = New OPCServer()
- _OPCServer.Connect("OSI.DA.1")
- Debug.WriteLine(" End : Create OPCServer")
- ' Setting Update Rate 1000[ms]
- Debug.WriteLine("Start : Setting Update Rate")
- _OPCGroups = _OPCServer.OPCGroups
- _OPCGroup = _OPCGroups.Add("Group1")
- _OPCGroup.UpdateRate = 1000
- Debug.WriteLine(" End : Setting Update Rate")
- ' Enable Advise Function
- Debug.WriteLine("Start : Enable Advise Function")
- _OPCGroup.IsActive = True
- _OPCGroup.IsSubscribed = _OPCGroup.IsActive
- Debug.WriteLine(" End : Enable Advise Function")
- ' Setting Watch Tag(TAG1 ~ TAG8)
- Debug.WriteLine("Start : Setting Watch Tag")
- _OPCItems = _OPCGroup.OPCItems
- For i As Integer = 1 To ITEM_MAX
- ItemName(i) = "TAG" & i
- HandleClient(i) = i
- Next
- _OPCItems.AddItems( _
- ITEM_MAX _
- , ItemName _
- , HandleClient _
- , ServerHandles _
- , Errors _
- )
- For i As Integer = 1 To ITEM_MAX
- If Errors(i) = 0 Then
- HandleClient(i) = ServerHandles(i)
- Debug.WriteLine( _
- "ItemName[" _
- & i _
- & "] : Regist Success." _
- )
- Else
- Debug.WriteLine( _
- "ItemName[" _
- & i _
- & "] : Regist Failure." _
- )
- End If
- Next
- Debug.WriteLine(" End : Setting Watch Tag")
- End Sub
- Private Sub OPCGroup_DataChange( _
- ByVal TransactionID As Integer _
- , ByVal NumItems As Integer _
- , ByRef ClientHandles As System.Array _
- , ByRef ItemValues As System.Array _
- , ByRef Qualities As System.Array _
- , ByRef TimeStamps As System.Array _
- ) Handles _OPCGroup.DataChange
- Debug.WriteLine("DataChanged")
- Debug.WriteLine("TransactionID : [" & TransactionID & "]")
- Debug.WriteLine("NumItems : [" & NumItems & "]")
- For i As Integer = 1 To NumItems
- Debug.WriteLine( _
- "Rec[" & i & "] : " _
- & "ItemValues : [" & ItemValues(i) & "]" _
- & " / Qualities : [" & Qualities(i) & "]" _
- & " / TimeStamps : [" & TimeStamps(i) & "]" _
- )
- Next
- End Sub
- Private Sub OPCGroup_AsyncReadComplete( _
- ByVal TransactionID As Integer _
- , ByVal NumItems As Integer _
- , ByRef ClientHandles As System.Array _
- , ByRef ItemValues As System.Array _
- , ByRef Qualities As System.Array _
- , ByRef TimeStamps As System.Array _
- , ByRef Errors As System.Array _
- ) Handles _OPCGroup.AsyncReadComplete
- Debug.WriteLine("AsyncReadComplete")
- Debug.WriteLine("TransactionID : [" & TransactionID & "]")
- Debug.WriteLine("NumItems : [" & NumItems & "]")
- For i As Integer = 1 To NumItems
- Debug.WriteLine( _
- "Rec[" & i & "] : " _
- & "ItemValues : [" & ItemValues(i) & "]" _
- & " / Qualities : [" & Qualities(i) & "]" _
- & " / TimeStamps : [" & TimeStamps(i) & "]" _
- )
- Next
- End Sub
- Private Sub OPCGroup_AsyncWriteComplete( _
- ByVal TransactionID As Integer _
- , ByVal NumItems As Integer _
- , ByRef ClientHandles As System.Array _
- , ByRef Errors As System.Array _
- ) Handles _OPCGroup.AsyncWriteComplete
- Debug.WriteLine("AsyncWriteComplete")
- Debug.WriteLine("TransactionID : [" & TransactionID & "]")
- Debug.WriteLine("NumItems : [" & NumItems & "]")
- End Sub
- Private Sub OPCGroup_AsyncCancelComplete( _
- ByVal CancelID As Integer _
- ) Handles _OPCGroup.AsyncCancelComplete
- Debug.WriteLine("AsyncCancelComplete")
- Debug.WriteLine("CancelID : [" & CancelID & "]")
- End Sub
- End Class
-
Re: A failuare of generating OSIDAAuto.OPCServer
spilon 2011-2-23 下午6:28 (回复 dorisliper)What you seem to be using is a .NET Interop assembly that was automatically generated from the COM-based OPC Automation Interfaces we ship with our products. I personally do not have experience with using these "wrappers" and we actually never encouraged or taught how to use them.
Typically, when you want to develop something OPC in .NET, you need to use the OPC .NET Automation Wrapper or the OPC .NET API. The former is intended to facilitate porting existing VB6 applications over to VB.NET, whereas the latter is the recommended approach for new OPC applications in .NET (whether in VB.NET or C#). For more information, please see the "OPC - Past, Present and Future" webinar under the vCampus Auditorium, or the PI Application Development Training course materials.
Hope this helps!
-
Re: A failuare of generating OSIDAAuto.OPCServer
spilon 2011-2-24 下午1:29 (回复 spilon)Would you happen to be on a 64-bit machine? I dug this up a little more, and the Class ID you listed up there (at the least the 14 first characters) seem to point to the OSIDAAuto.dll COM library. This is a 32-bit library. You will have to force your .NET application to build for 32-bit because 64-bit stuff cannot call 32-bit DLLs.
-
Re: A failuare of generating OSIDAAuto.OPCServer
spilon 2011-2-24 下午4:28 (回复 spilon)Out of curiosity, I tried to make this code you posted earlier, but could not. I get past the creation of the OPCServer, but cannot seem to access/initialize the OPCGroups collection. After doing some research, it the seems like there is a problem in how .NET Interop was generated and how it deals with the underlying COM components. It seems like you can use it in the .NET Framework 1.1, but not in later version (like 3.5, which you are using). I found several other posts on forums on the Web, where people shared the same issue (for different OPC Servers, not OSIsoft's) and nobody found an answer.
Per one of my previous posts, this library you are using is not something "official" or even supported. I strongly recommend you use one of the official alternatives:
- OPC DA Automation Wrapper (also known as the "OPC .NET RCWs MergeModule")
- OPC .NET API (they have version 1.3 for .NET 1.0/1.1, and version 2 for .NET 2.0)
- OPC .NET 3.0 (a WCF-based SDK, formerly known as OPC Xi)
Hope this helps!
-
Re: A failuare of generating OSIDAAuto.OPCServer
spilon 2011-2-24 下午4:29 (回复 spilon)Oh, I forgot: please consult the OPC Foundation website (www.opcfoundation.org) for more information on all this.
-
Re: A failuare of generating OSIDAAuto.OPCServer
dorisliper 2011-3-1 上午11:00 (回复 spilon)Hi Pilon!
Thanks for letting me know.
I appreciate that.
I'll try with OPC .NET3.0.
-
-
-
-
-
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
2016-12-01 WeX5 - AJAX跨域调用相关知识-CORS和JSONP