Sign in to follow this  
Followers 0
phuz

VB.NET / OPC

16 posts in this topic

I am running out of options for troubleshooting this, so I am hoping someone here can help or point me in the direction of someone who could. I have a VB.NET (.NET 2.0) application that uses the Interop.OPCAutomation.dll wrapper. It was developed on Computer A and works fine. The source code was then transferred to Computer B where it throws an error and will not test successfully. Computer A: Intel i7, Windows 7 Ultimate 64 bit SP1, Visual Studio 2012 Computer B: AMD six-core, Windows 7 Ultimate 64 bit SP1, Visual Studio 2012 These application does not have 32-bit and 64-bit dlls, so it shouldn't matter, but even so, they are both 64-bit systems. On Computer A, the application will connect to the OPC server and read/write values that I have without a hitch. On Computer B, when I attempt to connect to the OPC server (which is a mirror setup of the OPC server on Computer A), I get this error: Error HRESULT E_FAIL has been returned from a call to a COM component System.Runtime.InteropServices.COMException was unhandled ErrorCode=-2147467259 Message=Error HRESULT E_FAIL has been returned from a call to a COM component. Source=Interop.OPCAutomation StackTrace: at OPCAutomation.OPCServerClass.Connect(String ProgID, Object Node) at Weather.Form1.btnConnect_Click(Object sender, EventArgs e) in C:\Users\keperling\Desktop\Weather Data\Form1.vb:line 678 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at Weather.Form1.Main() in C:\Users\keperling\Desktop\Weather Data\Form1.vb:line 0 InnerException: The code that occurs at Line 678 is: OPCMyServer.Connect("KEPware.KEPServerEx.V4", "localhost") Again, this identical OPC server is setup on Computer A. I have spent about 12 hours trying to determine what is different between the two systems, but there is nothing that sticks out.

Share this post


Link to post
Share on other sites
Aren't OPC Automation dll's registered during installation? Did you just copy the source code, or did you actually install OPC Automation's suite on computer B? Did you try to re-install OPC Automation suite on computer B?

Share this post


Link to post
Share on other sites
Yes they are installed then. To computer B, I tried two things. Copying the published application and installing it. It installs fine, runs, but errors when trying to connect. That is when I decided to install VStudio on that computer too and copy the source code for further debugging (because I wasn't having any of these issues on computer A). Same error after installing Visual Studio and trying to test the source code. I should also mention that I installed a very similar application on a customer's computer (windows 7 professional 64) and installed it without issue. The only thing I had to do extra was add the OPC topic in RSLinx, obviously. It fired right up and has been working great for over a month so far. It clearly has to do with something either installed or missing on Computer B, and I have no idea how to tell what it is because this "HRESULT E_FAIL" error seems kind of vague. It doesn't provide any additional troubleshooting, except that it points to the Interop.OPCAutomation.dll.

Share this post


Link to post
Share on other sites
Have you checked with OPC Automation what this error code means? EDIT: It does seem like the error is related to the OPC Automation component... Edited by kaare_t

Share this post


Link to post
Share on other sites
No, that was actually my point of this post. I don't know who I can contact. The OPC foundation closed its forums last year, and the error isn't specific. It's a generic HRESULT exception that merely points to the OPC dll. The problem lies within Windows somewhere, but I don't know where and even where to begin.

Share this post


Link to post
Share on other sites
Check DCOM: Component Services > Computers > Right click on My Computer > Properties > MSDTC tab > Security Configuration ... (Button) > check 'Network DTC Access' > select 'No Authentication Required' option Try this. Found it on a simple google search... You might have some issues (one or more) with the DCOM config on the new computer... Maybe...

Share this post


Link to post
Share on other sites
Yeah I came across this last night too, but my MSDTC tab has no option for Security Configuration. Maybe its an XP thing? Edited by phuz

Share this post


Link to post
Share on other sites
Ahhh, I don't have Win7, but maybe you could try this descriptive guide: http://www.aggsoft.com/asdl-dcom-opc-config-windows-8-2012-4.htm I would guess, after googling a bit, that it is a DCOM and/or access or elevation problem with the OPC application/Windows application.

Share this post


Link to post
Share on other sites
Yes, the permissions all look good.

Share this post


Link to post
Share on other sites
Both in DCOM and in the Local Security Policy? And of course you've tried to disable the firewall? Authentication and impersonation is also correct in the DCOM config? Also the OpcEnum component (found under DCOM Config folder) is set correctly?

Share this post


Link to post
Share on other sites
Yes, and I suspected they would be. They were never changed and they match what is on Computer A. I have tried disabling the firewall, but the application runs fine with the firewall enabled on Computer A, so firewall status shouldn't matter on B.

Share this post


Link to post
Share on other sites
OK, got past that error, but now have an error that I actually had a long time ago, but the circumstances are different. It relates to creating the OPCGroups. I downloaded Kepware's sample VB.NET app. Of course it works fine on Computer A, but fails on Computer B. I get the exact same error on Kepware's sample app as I do in my own code. This error occurs when clicking the "Add Group" button. Here's a screenshot: Edited by phuz

Share this post


Link to post
Share on other sites
SOLVED! And I don't know why. For the heck of it, I copied the OPCDAAuto.dll from the working machine to my non-working one. They had the same file dates, size, and version. I un-registered it, then re-registered it. And now it works. I'd love to know why this had any effect. I mean I am glad it works, but I also like to make sense of things and this doesn't.

Share this post


Link to post
Share on other sites
Did you make ANY changes to the computer (DCOM/LocalSecurityPolicy/Installing or uninstalling/.NET Framework and so on) after you installed the suite the first time? -> In other words, did anything change between registration 1 and registration 2 of the .dll? Registration of objects can indeed fail without giving you any message, e.g. if dependencies and/or other components are not in place when registering it can in some cases fail without causing any visible errors. It could be caused by a lot of reasons, but my guess is that: Something changed on the computer between registration 1 and registration 2 that caused the correct dependencies to be present during registration 2 It's hard to find out now that everything is working again, but if you have a third computer (test computer or similar), try to do exactly the same once again, and install the components, software and libraries in the same order as you've already done, and see what happens.

Share this post


Link to post
Share on other sites
Nothing changed, at least intentionally. This base code for connecting to the OPC server has already been installed on a third computer (A customer's computer running Windows 7 Professional 64 bit) and it fired right up. I'm guessing this OPCDAAuto was corrupted somehow. Lesson learned? Computers are silly.

Share this post


Link to post
Share on other sites

I have a same problem, may you help me with me conection, i have windows 7 64 bits, kepware 5 and Visual Studio 2008, on Windows 32 bits my application runs fine but on windows 64 not.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0