Visual Studio Error Codes

Gadelric

Member
Join Date
Nov 2018
Location
Midwest
Posts
137
Wizards,

I have an application that is built in Visual Studio 2019.
I have been getting an error from the program that is very generic.
The developer sent me in a direction that was not the issue, the equipment they said was having issues was replaced, I didn't have the replacements port set correctly and we received the error associated with the board "not working".

This leads me to believe the issue we started with was not related to the board that I was recommended to replace as we are still getting the original error with the board replaced.

I have the program and all associated files for this backed up onto a computer that has visual studios.

Is there a way that I could dig through the code to find where this error is triggered so that I could at least have some idea as to what is causing the error?

The station is a very simple station, 1 computer/monitor, 1 relay board and 1 amp meter.
I am currently waiting for production to go to lunch so I can switch the network cable to a dedicated line that goes from station directly to the main PLC switch. Current set up has this station daisy chained through multiple ops. Although I can not confirm this is network related, having a dedicated line will at least remove the daisy chain.
The error we get is random, could be several times a shift, could be a couple weeks between errors.

Any advice is appreciated.

Gad
 
I presume that the application is crashing randomly? If so, what is the error message that is being generated by visual studio? I would start there first. If you have the source code, then on a laptop with Visual Studio installed on it, try running it in the Visual Studio IDE (Debug) and let it run until it crashes. You'll need to have proper communications established from the application on the laptop, to the machine. Once you have that established, run it (Debug---->Start Debugging). Then walk away and let it run. When it crashes again, it will stop at the portion of the code and display a graphic showing you the line/s of code where it had a problem.

Do you know what programming language the application was written in? If it's Visual Basic, the "Form" in the Solution Explorer will end with ".vb". If it's in C#, it will be ".cs". Either way, right click on the main form in the Solution explorer and then select "View Code". Sounds like it's a simple machine, so probably only one file with the source code in it.

Also, is the station in question fully automated? I mean, if its an operator at the stations that clicks on stuff, I would try and find out if its something specific that the operator clicks on when the crash happens. For instance, if its a particular button that gets clicked, and then the crash happens, then you know to start at that button's code in the application source code.
 
Last edited:
@busarider has a great idea about building debug executable and running it in the IDE, although waiting for the error for a few days in VS2019 might be ... awkward.



If the error message is part of the application and not generic Windows/VS2019 (e.g. not "COM2 device does not exist"), you can search for strings in the source code using the IDE see https://code.visualstudio.com/docs/editor/codebasics#_search-across-files.


Also, you don't have to be running the app to do this, or even have it built into an executable (.exe) file.
 
Last edited:
So I haven't worked much with PLCs and VS together, but back in the day when I did coding more than laddering, there are ways to throw meaningful exceptions in code, and instead of just having function calls, do this:

https://docs.microsoft.com/en-us/do...e/exceptions/creating-and-throwing-exceptions

This needs to be a request you need to raise to the devs, they would be fully aware on how to make their program have exception handling.

Also, I just linked to C# exceptions as an assumption, all languages have some sort of error handling/exception mappings.
 
Sorry for the confusion,

The error is produced by the application.
There are 3 errors we have seen from this beast.
1.) OPC---- related to rslinx not running
2.) Relay board port------ related to relay board not being connected physically or port assignment is incorrect.
3.) Unable to read switches---- unknown cause (Developer said they "think" this was caused by the relay board not being connected, but that turned out to be incorrect)

I don't have the option to leave my laptop integrated into this line as I need it, my dev pc that has VS on it is an offline pc that only connects to my development PLC.

My best option at the moment is to try and see if I can locate where in the application the error is thrown, and then do some deductive reasoning as to why we might be getting this.

For now, the machine has a dedicated network line to the PLC main switch. The operator asked if I worked on it while he was at lunch, because he noticed the station is quicker to respond to the cycle start swipe.
 
3.) Unable to read switches---- unknown cause


that sounds like a custom error message, so unless it is in a driver DLL, I suspect you will be able to find the code with that string in it.


Even if it's in the driver, there is probably only one or a few reads of the switches, so that would still enable narrowing down the code where it happens, although if it is in a DLL driver it is unlikely you will be able to do anything about it.


If this is happening over a network (OP said they were running a dedicated network cable) and the protocol is over TCP/IP, can you fire up a continuous ping to the device (ping -i, IIRC)? that might show if there was a network issue at the same time as the problem.


If it is TCP/IP, wireshark or tcpdump is another diagnostic tool.
 
Last edited:
Found this:

Function StartRestartSwitch() As Boolean
'Function Returns The State Of The Start Restart Switch

Try
Dim value As Integer = RelayBoardPort.ProXR.AD8.Read8BitsValue(0)

Select Case value
Case Is < 127
frmMain.osStartRestartSwitch.BackColor = Color.LimeGreen
Return True
Case Else
frmMain.osStartRestartSwitch.BackColor = Color.WhiteSmoke
Return False
End Select

Catch ex As TimeoutException
WritetoErrorLog(ex, True, True, "Error Occured In: " & New StackTrace().GetFrame(0).GetMethod.ToString, True, "There Was An Error Reading The Switches : An Exception Was Thrown See Error Log For Details")
End Try



This appears to be what I was looking for.
It does appear that this is related to the relay board, but the try case statement makes me think this is an optical function call that displays the indicator color when you swipe cycle start. But when we get the error, you can swipe cycle start and the indictor will flash from white to green.

o_O
 
If this is happening over a network (OP said they were running a dedicated network cable) and the protocol is over TCP/IP, can you fire up a continuous ping to the device (ping -i, IIRC)? that might show if there was a network issue at the same time as the problem.



I do have a small pc that displays camera images for the operators, I will run a ping test, I think continuous ping is -t, will see what happens.
Unfortunately, things run great for unknown amounts of time.. this ping could run for 10 min, or 10 days before I see the error pop up.
 
...
Unfortunately, things run great for unknown amounts of time.. this ping could run for 10 min, or 10 days before I see the error pop up.


yes, that is a problem, this may help


  1. put a lot of lines in the terminal, or run the ping output to a file and hope the disk is big enough.
  2. write a script that loops
    1. sending 60 pings at 1s intervals (not -t)
    2. then writing a timestamp.

if the PC has WSL this could be easier than a .BAT file.
 
Follow up:


Team,

So far so good, reports I am getting after running the dedicated network cable is "line ran great".

Gad
 
Of those 8 relays (bits) read by that code, which bit is the "Start Restart Switch?"

Because there may be a bug in that code; I'm not saying it is related to the error you are finding, and neither is there any guarantee that it will ever show up in operation, but it does look like a bug.
 
Last edited:
Of those 8 relays (bits) read by that code, which bit is the "Start Restart Switch?"

Drbitboy,

I am not entirely sure, I have reached back out to the developer but with the support I have received in the past, I don't expect a reply soon...

I will try to dig around some more to see what I can see.
 
Does the error message show this complete string:


"There Was An Error Reading The Switches : An Exception Was Thrown See Error Log For Details"
?


Do you know where the Error Log? Can you find the WriteToErrorLog routine in the code?


Is this and NCD Fusion device, and is it communicating via RS-232?
 
I pulled more logs from the system last night.
It appears this error has been seen ever since this machine was brought to this plant, about a year before I was brought in.

The computer communicates with the board via usb.

Still have not had any reports of this error showing back up, for now its a sleeping gremlin that will wake up and make my day miserable soon enough.
 
I pulled more logs from the system last night.
It appears this error has been seen ever since this machine was brought to this plant, about a year before I was brought in.

The computer communicates with the board via usb.

Still have not had any reports of this error showing back up, for now its a sleeping gremlin that will wake up and make my day miserable soon enough.

Don't get it wet.
 

Similar Topics

I am having difficulty finding documentation or examples on integrating Visual Studio with iX Developer in order to develop custom objects...
Replies
0
Views
523
Hello, I am working on a project currently that uses a windows application on a PC to communicate with an NX1P2 controller to read and write...
Replies
2
Views
973
Hi I'm currently doing a college course in robotics and automation and a question we were asked was. A software application used by production...
Replies
10
Views
3,613
Hi All I have been switching between 2017 and 2019, all depending on which one i found more stable, at the moment I use 2019 I was just...
Replies
1
Views
1,458
Hi, I have an odd problem that consumes a lot of precious time. I will often lose contact with the TwinCAT System Service, and be completely...
Replies
1
Views
1,349
Back
Top Bottom