mheyman / Isopoh.Cryptography.Argon2

Fully managed .Net Core implementation of Argon2
Other
196 stars 9 forks source link

System.TypeInitializationException with .NET native on UWP #37

Open jp-weber opened 3 years ago

jp-weber commented 3 years ago

If compilation is activated in the release mode with .NET native, the following error message appears:

System.TypeInitializationException: 'A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.'
Inner exception:
TypeLoadException: Unresolved P/Invoke method 'libSystem!OsxMemset' from this method. Please look for this method in build warnings for more details. 

   at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext* pContext) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\src\System\Runtime\CompilerServices\ClassConstructorRunner.cs:line 114
   at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstruction(Void* returnValue, StaticClassConstructionContext* pContext) in f:\dd\ndp\fxcore\CoreRT\src\System.Private.CoreLib\src\System\Runtime\CompilerServices\ClassConstructorRunner.cs:line 37
   at Isopoh.Cryptography.SecureArray.SecureArray..ctor(SecureArrayCall call)
   at Isopoh.Cryptography.SecureArray.SecureArray`1..ctor(Int32 size, SecureArrayType type, SecureArrayCall call)
   at Isopoh.Cryptography.SecureArray.SecureArray`1.Best(Int32 size, SecureArrayCall secureArrayCall)
   at Isopoh.Cryptography.Argon2.Argon2.Hash(String password, String secret, Int32 timeCost, Int32 memoryCost, Int32 parallelism, Argon2Type type, Int32 hashLength, SecureArrayCall secureArrayCall)
   at Isopoh.Cryptography.Argon2.Argon2.Hash(String password, Int32 timeCost, Int32 memoryCost, Int32 parallelism, Argon2Type type, Int32 hashLength, SecureArrayCall secureArrayCall)

compiling with net native produces the following errors:


microsoft.net.native.compiler\2.2.9-rel-29512-01\tools\Microsoft.NetNative.targets(805,5): warning :
MCG : warning MCG0007: Unresolved P/Invoke method 'psapi.dll!GetProcessMemoryInfo' for method 'System.Boolean Isopoh.Cryptography.SecureArray.WindowsNative.UnsafeNativeMethods.GetProcessMemoryInfo(System.IntPtr, Isopoh.Cryptography.SecureArray.WindowsNative.UnsafeNativeMethods.ProcessMemoryCounters, System.UInt32)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'ntdll.dll!RtlZeroMemory' for method 'System.Void Isopoh.Cryptography.SecureArray.WindowsNative.UnsafeNativeMethods.RtlZeroMemory(System.IntPtr, System.UIntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libSystem!mlock' for method 'System.Int32 Isopoh.Cryptography.SecureArray.OsxNative.UnsafeNativeMethods.OsxMlock(System.IntPtr, System.UIntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libSystem!munlock' for method 'System.Int32 Isopoh.Cryptography.SecureArray.OsxNative.UnsafeNativeMethods.OsxMunlock(System.IntPtr, System.UIntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libSystem!memset' for method 'System.IntPtr Isopoh.Cryptography.SecureArray.OsxNative.UnsafeNativeMethods.OsxMemset(System.IntPtr, System.Int32, System.UIntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libc!mlock' for method 'System.Int32 Isopoh.Cryptography.SecureArray.LinuxNative.UnsafeNativeMethods.LinuxMlock(System.IntPtr, System.UIntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libc!munlock' for method 'System.Int32 Isopoh.Cryptography.SecureArray.LinuxNative.UnsafeNativeMethods.LinuxMunlock(System.IntPtr, System.UIntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libc!memset' for method 'System.IntPtr Isopoh.Cryptography.SecureArray.LinuxNative.UnsafeNativeMethods.LinuxMemset(System.IntPtr, System.Int32, System.UIntPtr)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libc!getrlimit' for method 'System.Int32 Isopoh.Cryptography.SecureArray.LinuxNative.UnsafeNativeMethods.LinuxGetRLimit(System.Int32, Isopoh.Cryptography.SecureArray.LinuxNative.UnsafeNativeMethods.LinuxRlimit)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libc!setrlimit' for method 'System.Int32 Isopoh.Cryptography.SecureArray.LinuxNative.UnsafeNativeMethods.LinuxSetRLimit(System.Int32, Isopoh.Cryptography.SecureArray.LinuxNative.UnsafeNativeMethods.LinuxRlimit)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libc!strerror_r' for method 'System.IntPtr Isopoh.Cryptography.SecureArray.LinuxNative.UnsafeNativeMethods.LinuxSterrorR(System.Int32, System.IntPtr, System.UInt64)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'libc!sysctl' for method 'System.Int32 Microsoft.DotNet.PlatformAbstractions.Native.NativeMethods.Darwin.sysctl(System.Int32*, System.UInt32, System.Byte*, System.UInt32*, System.IntPtr, System.UInt32)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
MCG : warning MCG0007: Unresolved P/Invoke method 'ntdll!RtlGetVersion' for method 'System.Int32 Microsoft.DotNet.PlatformAbstractions.Native.NativeMethods.Windows.RtlGetVersion(Microsoft.DotNet.PlatformAbstractions.Native.NativeMethods.Windows.RTL_OSVERSIONINFOEX)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.````