Hi there
Excuse me for posting a very basic question, but I'm completely new to this fit format.
I'm trying to generate a fit file from scratch, to begin with I'm just trying to include some trackpoints.
I'm using the SDK and tried to modify the Encode example in C#.
I have created a fit file, but it seems like it's missing some fields, I have tried to convert the fit file to a tcx file using 
http://fit2tcx.runalyze.de/ and the tcx file contains the error message: not an activity.
I have attached my generated fit file.
Below is the code I have made until now.
Any help is greatly appreciated.
Br
Kenth
static void EncodeFile()
        {
            System.DateTime systemTimeNow = System.DateTime.Now;
            System.DateTime systemTimeStart = System.DateTime.Now;
            FileStream fitDest = new FileStream("Example.fit", FileMode.Create, FileAccess.ReadWrite, FileShare.Read);
            // Create file encode object
            Encode encodeDemo = new Encode();
            // Write our header
            encodeDemo.Open(fitDest);
            // Generate some FIT messages
            FileIdMesg fileIdMesg = new FileIdMesg(); // Every FIT file MUST contain a 'File ID' message as the first message
            fileIdMesg.SetType(Dynastream.Fit.File.MonitoringB); // See the 'FIT FIle Types Description' document for more information about this file type.
            fileIdMesg.SetManufacturer(Manufacturer.Dynastream);
            fileIdMesg.SetProduct(1001);
            fileIdMesg.SetSerialNumber(54321);
            fileIdMesg.SetTimeCreated(new Dynastream.Fit.DateTime(systemTimeNow));
            fileIdMesg.SetNumber(0);
            encodeDemo.Write(fileIdMesg); // Write the 'File ID Message'
            FileCreatorMesg fileCreatorMesg = new FileCreatorMesg();
            fileCreatorMesg.SetHardwareVersion(1);
            fileCreatorMesg.SetSoftwareVersion(1);
            encodeDemo.Write(fileCreatorMesg);
            EventMesg eventMesg = new EventMesg();
            eventMesg.SetTimestamp(new Dynastream.Fit.DateTime(systemTimeNow));
            eventMesg.SetTimerTrigger(0);
            eventMesg.SetEvent(Event.Timer);
            eventMesg.SetEventType(EventType.Start);
            encodeDemo.Write(eventMesg);
            var latDegrees = 55.01;
            var lonDegrees = 12.01;
            
            RecordMesg recordMesg = new RecordMesg();
            //recordMesg.LocalNum = 1;
         
            for (int i = 0; i < 20; i++ )
            {
                latDegrees += 0.001;
                lonDegrees += 0.001;
                var latSemicircles = (int)(latDegrees * ((Math.Pow(2, 31)) / 180));                 var l * ((Math.Pow(2, 31)) / 180));
                recordMesg.SetTimestamp(new Dynastream.Fit.DateTime(systemTimeNow));
                recordMesg.SetActivityType(Dynastream.Fit.ActivityType.Cycling);
                recordMesg.SetPositionLat(latSemicircles);
                recordMesg.SetPositionLong(lonSemicircles);
                encodeDemo.Write(recordMesg);
                systemTimeNow = systemTimeNow.AddSeconds(1);
            }
            eventMesg = new EventMesg();
            eventMesg.SetTimestamp(new Dynastream.Fit.DateTime(systemTimeNow));
            eventMesg.SetTimerTrigger(0);
            eventMesg.SetEvent(Event.Timer);
            eventMesg.SetEventType(EventType.StopAll);
            encodeDemo.Write(eventMesg);
            
            LapMesg lapMesg = new LapMesg();
            lapMesg.SetTimestamp(new Dynastream.Fit.DateTime(systemTimeNow));
            lapMesg.SetTotalElapsedTime(20);
            lapMesg.SetMessageIndex(0);
            lapMesg.SetLapTrigger(LapTrigger.SessionEnd);
            encodeDemo.Write(lapMesg);
            eventMesg = new EventMesg();
            eventMesg.SetTimestamp(new Dynastream.Fit.DateTime(systemTimeNow));
            eventMesg.SetTimerTrigger(0);
            eventMesg.SetEvent(Event.Session);
            eventMesg.SetEventType(EventType.StopDisableAll);
            encodeDemo.Write(eventMesg);
            
             SessionMesg sessi SessionMesg();
            sessionMesg.SetTimestamp(new Dynastream.Fit.DateTime(systemTimeNow));
            sessionMesg.SetTotalElapsedTime(20);
            sessionMesg.SetMessageIndex(0);
            sessionMesg.SetSport(Sport.Cycling);
            encodeDemo.Write(sessionMesg);
            ActivityMesg activityMesg = new ActivityMesg();
            activityMesg.SetTimestamp(new Dynastream.Fit.DateTime(systemTimeNow));
            activityMesg.SetTotalTimerTime(20);
            activityMesg.SetNumSessions(1);
            activityMesg.SetEvent(Event.Workout);
            activityMesg.SetEventType(EventType.StopAll);
            activityMesg.SetType(Activity.Manual);
            encodeDemo.Write(activityMesg);
            // Update header datasize and file CRC
            encodeDemo.Close();
            fitDest.Close();
        }