question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Newtonsoft.Json nuget package fails on Electron.NET app

See original GitHub issue
  • Version: 13.5.1

NET 5 or NET 6 (tried both), Node: v16.14.0

  • Target: Windows to start with

This is likely an issue with the versioning pattern of Newtonsoft.json but good to note if anyone else encounters this issue. You can grab a copy of my repo to reproduce the issue. https://github.com/domingoladron/LearnBlazor.ElectronNet/tree/bug/json-net-electon-net

It appears that if you run up a Blazor app inside Electron.NET and try to call anything using Newtownsoft.Json library (tried both 13.01 and 12.03), it will fail with the following error:

FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.

If you try this same thing when running the app as a web app (IIS, Docker, etc.) it works fine.

I’ve added a blob of simple JSON deserialisation using the Newtonsoft.JSON JsonConvert class to the Index.razor page to show the error when you run up the Electron.NET app.

//just calling Newtownsoft.Json class to fire the exception
 
 var fakeClassData = JsonConvert.DeserializeObject<FakeClass>(await File.ReadAllTextAsync(Path.Join(Environment.CurrentDirectory, "fakefile.json")));

I think this has to do with how Newtownsoft.JSON versions packages. While the package is labeled 13.0.1, internally, the package itself is versioned ‘13.0.0’ and the app running in Electron.NET can’t find it.

Steps to Reproduce:

  1. Including Newtonsoft.JSON to your web app as a nuget package

  2. Call some code from within the Newtonsoft.JSON package

  3. Start the app as a website. Everything will run fine image

  4. Start the app via electronize. It will bomb immediately upon hitting the Newtownsoft.JSON code image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
Melethainielcommented, Apr 22, 2022

It seems not to be only newtonsoft library. I got the same error with epplus. Last month it was working well.

0reactions
domingoladroncommented, Jun 14, 2022

Updating my NuGet packages to 6.0.5 solved my problems.

I’ll give that a try and close the bug if that sorts it. Cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

Newtonsoft dependency problem with Syncfusion ...
After adding the required Syncfusion Nuget packages and building I found there is a dependency upon Newtonsoft.Json 12.0.0.0.
Read more >
ElectronNET.API 0.0.2
Building cross platform electron based desktop apps with .NET Core and ... This package contains the API to access the "native" electron API....
Read more >
ElectronCGI - Cross Platform .Net Core GUIs with Electron
ElectronCGI enables node apps to perform requests that are served by .Net. This is useful for UIs built with Electron that want to...
Read more >
Error BLAZORSDK1001 The project references the ASP. ...
I started a fresh new blazor wasm project, Compiled and ran it. Untill that point every thing was fine. I try to add...
Read more >
Create a desktop app with Electron, React and C# | ...
If we execute the npm start, we should get a popup error from Electron. ... In Electron, the process that runs package.json 's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found