I have created one C# dll of .Net Framework 4.7.2. In this DLL, I want to deserialize the JSON file and when I have added the code for deserialization ,I got compilation error to install the NuGet package
After installing System.Text.Json NuGet package of latest version(5.0.2), dll builds successfully.
When I connect this Dll with the C++ application and calls the deserialization method of the DLL, at that time I got one run time exception stating that:
“Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.”
Solutions I Tried:
1) I tried to change in the app.config file with the value of the version which is specified in the error.
If you use Net Framework projects with xxx.config file, you could use bindingRedirect.
Add these in app.config file or web.config file:
="" publickeytoken="b03f5f7f11d50a3a" culture="neutral">
After changing in app. Config file , I got different run time exception:
“System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Buffers, Version=184.108.40.206, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.'”
I tried changing the version of System. Buffers also in config file, but still getting the same error.
2) I tried to install the System.Text.Json of version 4.7.2
In this version also I am getting the same System. Buffers error.
Note: If we use the .Net 5.0.0(Core version) then System.Text.Json already present in it as default but with this version we are not able the generate the .tlb file as Regasm.exe gives error while registering the dll and in .Net 5.0.0 Register for COM interop is also disabled.
Thank you in advance.