Utf8Json icon indicating copy to clipboard operation
Utf8Json copied to clipboard

Doesn't work with UWP C# projects.

Open SirDragonClaw opened this issue 7 years ago • 7 comments

I have used this to great effect in my WPF C# project but the nuget package doesn't seem to support C# UWP projects.

Is there any chance that this could be fixed?

I can't use this sadly if it only works on some of my projects.

Also MessagePack doesn't work either...

SirDragonClaw avatar Sep 29 '17 06:09 SirDragonClaw

Utf8Json supports .NET Standard 2.0. Currently UWP does not support .NET Standard 2.0. But VS preview may works, please try it and wait for fall creator update(?). https://blogs.msdn.microsoft.com/dotnet/2017/08/25/uwp-net-standard-2-0-preview/

neuecc avatar Sep 29 '17 07:09 neuecc

Fair enough and thanks for getting back to me :)

SirDragonClaw avatar Sep 29 '17 07:09 SirDragonClaw

VS 2017 version 15.4 supports .NET Standard 2.0 and UWP. https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes#15.4

neuecc avatar Oct 10 '17 07:10 neuecc

I've made UWP project and .NET Standard 2.0 project on Visual Studio 2017 version 15.5.5.6 (Community edition). .NET Standard 2.0 project simply serialize class object to json like below. JsonSerializer.ToJsonString(obj) UWP project get serialization result and display it on window. It works fine on debug build. But it throws exception below on release build.

Exception thrown: 'System.MissingMethodException' in Utf8Json.dll Exception thrown: 'System.TypeInitializationException' in System.Private.CoreLib.dll Exception thrown: 'System.TypeInitializationException' in System.Private.CoreLib.dll Exception thrown: 'System.TypeInitializationException' in System.Private.CoreLib.dll Exception thrown: 'System.TypeInitializationException' in System.Private.CoreLib.dll Exception thrown: 'System.TypeInitializationException' in System.Private.CoreLib.dll Exception thrown: 'System.TypeInitializationException' in System.Private.Interop.dll Unhandled exception at 0x00007FFBEDE980E9 (Windows.UI.Xaml.dll) in UseUtf8jsonInUWP.exe: 0xC000027B: アプリケーション内部例外が発生しました。 (parameters: 0x0000026CB41F6090, 0x0000000000000002).

The complete code is below. https://github.com/freedom8888/UseUtf8jsonInUwp

Same Exception occured when I call JsonSerializer.Deserialize(obj) method. Do you have any idea about the reason?

freedom8888 avatar Apr 14 '18 11:04 freedom8888

After I changed property below, release build stopped throwing exception. UWP project property -> Build -> uncheck "Compile with .NET Native tool chain"

I'm not sure about the reason.

freedom8888 avatar May 19 '18 03:05 freedom8888

Maybe requires code generation for AOT. https://github.com/neuecc/Utf8Json#pre-code-generationunityxamarin-supports

neuecc avatar May 19 '18 06:05 neuecc

After I changed property below, release build stopped throwing exception. UWP project property -> Build -> uncheck "Compile with .NET Native tool chain"

I'm not sure about the reason.

Thank you very much!! It also works with MsgPackCSharp

KerJen avatar Jun 19 '20 16:06 KerJen