Computer-Specific NullReferenceException when Instantiating Object EliteDangerousAPI

-2

I'm attempting to use the API provided by https://github.com/EliteAPI/EliteAPI, and have created a simple application as per the example provided on . This was working exactly as expected yesterday, until for some reason my desktop crashed, and since then the application crashes with a NullReferenceException whenever it tries to create a new EliteDangerousAPI object:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using EliteAPI;
using EliteAPI.Events;

namespace Elite_PI_Server
{
    class Program
    {
        private static EliteDangerousAPI EliteAPI;

        static void Main(string[] args)
        {
            DirectoryInfo playerJournalFolder = new DirectoryInfo(
            $@"C:\Users\{Environment.UserName}\Saved Games\Frontier 
Developments\Elite Dangerous");

            EliteAPI = new EliteDangerousAPI( playerJournalFolder );

            EliteAPI.Start();
        }
    }
}

I stripped the code down to the above, I had a friend test this code on his machine, and it runs fine. It ran fine on my machine until the crash I spoke of.

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=EliteAPI
  StackTrace:
   at EliteAPI.Status.StatusWatcher.Update()
   at EliteAPI.Status.StatusWatcher..ctor(EliteDangerousAPI api)
   at EliteAPI.EliteDangerousAPI.Reset()
   at EliteAPI.EliteDangerousAPI..ctor(DirectoryInfo JournalDirectory, Boolean SkipCatchUp)
   at Elite_PI_Server.Program.Main(String[] args) in     C:\Users\paul\source\repos\Elite-PI-Server-Console\Elite-PI-Server\Program.cs:line 22

For reference, i'm using Visual Studio Community Edition 2017 15.9.7. Any suggestions as to what I could try would be appreciated.

Considering the code was proven to work on another machine, I've attempted a few other heavy-handed methods which might seem a bit overkill:

I've tried uninstalling the nuget package for EliteAPI, clearing the nuget package cache and reinstalling.

I've tried completely reinstalling Visual Studio, and cleaning up the install with https://github.com/Microsoft/VisualStudioUninstaller.

Any suggestions would be highly appreciated. I feel like either something has become corrupt when my machine died, or i'm doing something stupid.

c#
asked on Stack Overflow Feb 17, 2019 by Paul Draper

1 Answer

1

I am the author of EliteAPI.

First of all, thank you for using the library! :)

I'm sorry to hear you're running into issues.

The error seems to occur when the API is trying to grab data from the Status.json file. Can you confirm you can find Status.json at C:\Users\<username>\Saved Games\Frontier Developments\Elite Dangerous. Also, are you running the API before or after you started the game?

Might also be best to have further contact on Discord, if you have it. This is our invite link: https://discord.gg/jwpFUPZ.

Thank you!

EDIT: Try to add EliteAPI.Logger.Log += (sender, arg) => Console.WriteLine(arg.Message); above EliteAPI.Start(); to see if any warnings are being given.

answered on Stack Overflow Feb 17, 2019 by Somfic • edited Feb 17, 2019 by Somfic

User contributions licensed under CC BY-SA 3.0