0

I am trying to build simple console application for encryption and decryption in C# using libsodium. I have installed libsodium-net I am using visual studio 2019 and have installed Visual studio 2015-2019 redistributable. The build is succeeding but when i am trying to run its throwing an exception:

**System.TypeInitializationException**: 'The type initializer for 'Sodium.SodiumCore' threw an exception.'
Inner Exception
MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.

Exception I have tried the solution listed here: Libsodium-net - Unable to load DLL 'libsodium.dll

But it didn't solve my problem. When I try to reinstall visual studio 2015 redistributable , it says setup failed because another version is already installed on the system.Installation error

kaashif
  • 41
  • 5
  • How are you consuming the method that is missing? Where is the code that you are using that compiled fine but throws exception on runtime? – Jamshaid K. May 24 '21 at 07:57
  • If you want a *simple* application, why not use the built in encryption APIs? Libsodium-net is a .net wrapper around around a native library, and these are common source of problems. To start with, you usually can no longer be platform independent. – JonasH May 24 '21 at 08:03
  • Seems like you're trying to use `.net framework` library from `.net core` or `.net`. If you really need to use this version of library then target `net48`/`net461` framework. If you can use newer version, then try to find netcore compatible version – JL0PD May 24 '21 at 08:07

0 Answers0