简体   繁体   中英

Windows 8 C# - Parse.ParseClient throwing exception 'TypeInitializationException'

I'm using the database system Parse (www.parse.com), which is correctly installed.

For some reason this:

  public App()
  {
    this.InitializeComponent();
    this.Suspending += OnSuspending;

    ParseClient.Initialize("appkey", "windowskey");  //this line throws the exception
                                                //keys are actually my keys 
  }

is throwing an exception 'TypeInitializationException'.

I have installed Parse to the project using 'Install-Package Parse' and 'using Parse' is included.

I'm not sure why the exception is being thrown, as it only gets thrown on certain projects. For example, I have a project with the EXACT same code that I copy/pasted into the new project that works in the old one but not in the new one.

So to recap, the exception is thrown in one project, and not the other. Anyone know why this exception is thrown?

Apparently there was a dependency with Newtonsoft.Json within the ParseClient.Initialize function call. I figured this out by catching the exception and saw that is said something about Newtonsoft.Json, so I installed the package with "Install-Package Newtonsoft.Json" in the package manager console and it fixed the problem.

So apparently parse needs Newtonsoft.Json? Anyway, it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM