EventLog.MessageWritten object reference not set to an instance of an object exception
 
            
                
                    vlima                
                
                     ✭                
            
                        
            
                    Hello, I would like to know why when I try to create an event handler for MessageWritten in some controllers I get the message object reference not set to an instance of an object exception. The source code in C# and the stacker trace are down below:
at ABB.Robotics.Controllers.EventLogDomain.EventLog.add_MessageWritten(EventHandler`1 value)
I have tried the code in controllers version 6.03.00 ; 6.05.00 ; 6.04.01 ; 6.06.00 and the interesting thing is that the version does not matter because I have tested in different controllers with the same version and sometimes I got the exception sometimes not. That makes me wonder what is causing that in some controllers I have the exception and others not...
                scanner = new NetworkScanner();
            scanner.Scan();
            controllers = scanner.GetControllers();
            ListViewItem item = null;
            foreach (ControllerInfo controllerInfo in controllers)
            {
                // Add the controllers which are detected to the ListView
                item = new ListViewItem(controllerInfo.IPAddress.ToString());
                item.SubItems.Add(controllerInfo.Id);
                item.SubItems.Add(controllerInfo.Availability.ToString());
                item.SubItems.Add(controllerInfo.IsVirtual.ToString());
                item.SubItems.Add(controllerInfo.SystemName);
                item.SubItems.Add(controllerInfo.Version.ToString());
                item.SubItems.Add(controllerInfo.ControllerName);
                listView1.Items.Add(item);
                item.Tag = controllerInfo;
                // Create an object controller foreach robot in the network and activate the event handler to log the Event Messages.
                Controller controller = new Controller(controllerInfo);
                try
                {
                    controller.EventLog.MessageWritten += (sender, e) => log_MessageWritten(sender, e, controller);
                }
                catch (Exception e)
                {
                }
Stacker trace:
at ABB.Robotics.Controllers.EventLogDomain.EventLog.GetCategory(Int32 id)
at ABB.Robotics.Controllers.EventLogDomain.EventLog.Subscribe(EventHandler`1 handler)Stacker trace:
at ABB.Robotics.Controllers.EventLogDomain.EventLog.GetCategory(Int32 id)
at ABB.Robotics.Controllers.EventLogDomain.EventLog.add_MessageWritten(EventHandler`1 value)
I have tried the code in controllers version 6.03.00 ; 6.05.00 ; 6.04.01 ; 6.06.00 and the interesting thing is that the version does not matter because I have tested in different controllers with the same version and sometimes I got the exception sometimes not. That makes me wonder what is causing that in some controllers I have the exception and others not...
0  
            Categories
- All Categories
- 5.6K RobotStudio
- 401 UpFeed
- 21 Tutorials
- 15 RobotApps
- 306 PowerPacs
- 407 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.9K Robot Controller
- 363 IRC5
- 80 OmniCore
- 8 RCS (Realistic Controller Simulation)
- 853 RAPID Programming
- 31 AppStudio
- 4 RobotStudio AR Viewer
- 19 Wizard Easy Programming
- 110 Collaborative Robots
- 5 Job listings