|
-
Sep 3rd, 2022, 09:58 PM
#1
JSON Between Framework and .NET5
I kind of screwed something up, but that's life.
I have an extensive program written in Framework. I then wrote a test application that can perform a series of iteration tests on some objects in one DLL. Unfortunately, I wrote the test application in .NET 5. For the most part, this has not caused a problem. However, I just ran into an issue, and I'm pretty sure it has to do with the fact that the program is Framework and the test app is .NET 5. I'm wondering if there is a way around it.
A recent test I added into the test app is testing a function in a class from a DLL. The function makes use of the JavaScriptSerializer class from System.Web.Extensions. The test app can't call the function in the DLL. It can create the class, but when it tries to call that function it crashes with an error saying that System.Web.Extensions doesn't exist. I believe that's true for .NET 5, since all the JSON stuff was replaced. I believe that all the other testing has largely functioned because it doesn't stray into that area, or anything else that changed from Framework to Core.
Is there a way around this other than moving the test app back to Framework?
I've found that working from Framework to Core puts up some interesting problems.
My usual boring signature: Nothing
 
-
Sep 4th, 2022, 10:00 AM
#2
Re: JSON Between Framework and .NET5
https://www.newtonsoft.com/json
Why using MS way? The git will put newer and newer versions. Making it hard for myself just to use MS Json is not something I would do.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Sep 4th, 2022, 10:25 AM
#3
Re: JSON Between Framework and .NET5
That's something I have been deliberately avoiding for this project. It creates a dependency that I don't want. In this particular case, it would work out reasonably well, but you should be aware that NewtonSoft is mostly for Framework use, as .NET5/6 have built in classes that do the job that NewtonSoft did, and do it pretty well as far as my uses have been concerned (I haven't used them extensively, but they seem pretty slick for what I have done). Using the System.Text.JSON classes would mean not bothering with NewtonSoft.
Still, since the DLL is framework, I can't use System.Text.JSON, so that's out.
The issue with this program is that I have to think carefully about dependencies because it is a plug-in system, which imposes some interesting constraints. In this case, I think I could get away with using NewtonSoft, though I'm not quite sure. The plugins can't, because they are self contained, and can't know what resources will be available to them, so if they were dependent on NewtonSoft, they'd have to take some steps to ensure that NewtonSoft was available, which wouldn't be easy to do.
In this case, I could get away with it in this very narrow case, since the DLL that holds the class being tested is part of the core functionality, but it would be annoying to add a dependency that would be used by a single function in a single class when there is an easy way to avoid the dependency. NewtonSoft is great, to be sure, but my specific needs are very simple, and the JavaScriptSerializer class, while limited, is entirely sufficient for this task...and being part of the framework, it is readily available for all the plugins.
The only issue is that I made the test platform .NET5 rather than framework, which I now realize was foolish. Mixing Framework and Core works right up until the point that it doesn't.
My usual boring signature: Nothing
 
-
Sep 4th, 2022, 12:59 PM
#4
Re: JSON Between Framework and .NET5
Here is a list of things supported and not in .NET5 also examples of ser deser, horrible things compared to Json.Net but suit yourself.
https://docs.microsoft.com/en-us/dot...ots=dotnet-5-0
I wasn't aware that MS is trying to push Json.NET to the side. Of course not be able to emulate 2/3 of Json.net tells me that they are not doing quite a good job...Probably end up buying and then deprecate it, as usual.
Lately I had another issue with MS Graph. Their self contained classes an MSAL are horrible,horrible,horrible and the samples are limited (p.e. I had to "borrow" a Java sample so I can attach a file). Git libraries, 2 lines and done. I don't know what MS is trying to pull but I haven't seen such BS don't give a F behavior since 1.1 Framework. Anyway, not chit chat so, good luck with your project.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|