﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>RoboticsConnection User Forum / RoboticsConnection Software Support / Serializer .NET Library  / Unhandled exception errror / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>RoboticsConnection User Forum</description><link>http://www.roboticsconnection.com/userForums/</link><webMaster>info@roboticsconnection.com</webMaster><lastBuildDate>Thu, 20 Nov 2008 21:39:30 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Unhandled exception errror</title><link>http://www.roboticsconnection.com/userForums/Topic568-6-1.aspx</link><description>I also moved this topic under the Serializer .NET Library topic.&lt;/P&gt;&lt;P&gt;Best Regards,</description><pubDate>Thu, 26 Jun 2008 07:27:24 GMT</pubDate><dc:creator>jsummerour</dc:creator></item><item><title>RE: Unhandled exception errror</title><link>http://www.roboticsconnection.com/userForums/Topic568-6-1.aspx</link><description>First of all, why are you attempting to new off a Thread?   Could you please explain, because this isn't needed at all.  Do you need to have a multithreaded application?  Maybe you have one application talking to many peripheral devices (one being the Serializer), and you want each one to run in their own thread?&lt;/P&gt;&lt;P&gt;The SerializerLib has two threads of execution.  The main thread handles invocations to the objects associated with the library, while the other handles communication with the Serializer.   So, using threads the way you are attempting to buys you nothing with respect to the Serializer.  &lt;/P&gt;&lt;P&gt;I think the reason you are seeing the error is because you define an instance of Program, 'p' in Main(), then you tell the new thread to invoke p.InitializeSerializer() when it starts.   However, the new thread knows nothing about the instance of 'p', which was instantiated in the main thread, nor does it know anything about 'serializer'.   When you attempt to instantiate a new Serializer() object in InitializeSerializer(), the library needs to have that instance of 'serializer', because it's going to go off and attempt to create it's needed threads.  Since 'serializer' doesn't exist in the new thread, an exception is thrown.  If you single step over the program, I suspect you will see this behavior.&lt;/P&gt;&lt;P&gt;If you can make a good case to me as to why you need the additional thread, I'll be glad to help you further.&lt;/P&gt;&lt;P&gt;I believe this link might be of use to you.  Notice how the Work class is defined outside of the Test class, and it hs all of it's members (Data) encapsulated in the class.  So, when the DoWork() and DoMoreWork() is invoked from Thread.Start(), it has instances of Data to work on:&lt;/P&gt;&lt;P&gt;     &lt;A href="http://msdn.microsoft.com/en-us/library/system.threading.threadstart.aspx"&gt;http://msdn.microsoft.com/en-us/library/system.threading.threadstart.aspx&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Best Regards,</description><pubDate>Thu, 26 Jun 2008 07:11:13 GMT</pubDate><dc:creator>jsummerour</dc:creator></item><item><title>Unhandled exception errror</title><link>http://www.roboticsconnection.com/userForums/Topic568-6-1.aspx</link><description>Hi all,&lt;br&gt;we are working on a summer robotics project at Mesa State College and have run into an early snag. &lt;br&gt;We have the serializer controller board with the bluetooth serial interface with one servo connected to servo pin 1 (digital 8). When we try to run this code: &lt;br&gt;&lt;br&gt;[i]using System;&lt;br&gt;using System.Collections.Generic;&lt;br&gt;using System.Linq;&lt;br&gt;using System.Text;&lt;br&gt;&lt;br&gt;using RoboticsConnection.Serializer;&lt;br&gt;using RoboticsConnection.Serializer.Components;&lt;br&gt;using RoboticsConnection.Serializer.Controllers;&lt;br&gt;using RoboticsConnection.Serializer.Ids;&lt;br&gt;using RoboticsConnection.Serializer.Sensors;&lt;br&gt;&lt;br&gt;namespace ServoApp&lt;br&gt;{&lt;br&gt;    class Program&lt;br&gt;    {&lt;br&gt;        Serializer serializer;&lt;br&gt;        ServoMotorController antennaServo;&lt;br&gt;&lt;br&gt;        private void InitializeSerializer()&lt;br&gt;        {&lt;br&gt;            serializer = new Serializer();&lt;br&gt;            serializer.BaudRate = 19200;&lt;br&gt;            serializer.PortName = "COM40";&lt;br&gt;            serializer.CommunicationStarted += new SerializerEventHandler(serializer_CommunicationStarted);&lt;br&gt;&lt;br&gt;&lt;br&gt;            antennaServo = new ServoMotorController(serializer);&lt;br&gt;            antennaServo.ServoMotorId = ServoMotorId.ServoMotor1;&lt;br&gt;            antennaServo.Position = -100;&lt;br&gt;&lt;br&gt;            serializer.Run();&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        void serializer_CommunicationStarted(Serializer sender)&lt;br&gt;        {&lt;br&gt;            serializer.BlinkLED(LedId.Led1, 50);&lt;br&gt;            serializer.BlinkLED(LedId.Led2, 100);&lt;br&gt;            serializer.Units = Units.English;&lt;br&gt;        }&lt;br&gt;&lt;br&gt;        static void Main(string[] args)&lt;br&gt;        {&lt;br&gt;            Program p = new Program();&lt;br&gt;&lt;br&gt;            System.Threading.Thread thread = new System.Threading.Thread(&lt;br&gt;                new System.Threading.ThreadStart(p.InitializeSerializer));&lt;br&gt;            thread.Start();&lt;br&gt;&lt;br&gt;&lt;br&gt;            for (int position = -99; position &lt;= 100; ++position)&lt;br&gt;            {&lt;br&gt;                p.antennaServo.Position = position;&lt;br&gt;                for (int i = 0; i &lt; 100000; ++i) { ; }&lt;br&gt;            }&lt;br&gt;            p.serializer.ShutDown();&lt;br&gt;        }&lt;br&gt;&lt;br&gt;    }&lt;br&gt;}[/i]&lt;br&gt;&lt;br&gt;we get this error:&lt;br&gt;&lt;br&gt;[i]Unhandled Exception: System.NullReferenceException: Object reference not set to&lt;br&gt;an instance of an object.&lt;br&gt;   at RoboticsConnection.Serializer.Internal.CommunicationTask.ThreadProc()&lt;br&gt;   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)&lt;br&gt;   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C&lt;br&gt;ontextCallback callback, Object state)&lt;br&gt;   at System.Threading.ThreadHelper.ThreadStart()&lt;br&gt;&lt;br&gt;[/i]&lt;br&gt;&lt;br&gt;&lt;br&gt;Does anyone have any ideas on what might be wrong here?&lt;br&gt;Thanks &lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;</description><pubDate>Tue, 24 Jun 2008 17:22:23 GMT</pubDate><dc:creator>caquinto</dc:creator></item></channel></rss>