Closed why5684784 closed 2 years ago
getdomainname
is used by CommonUnixIPGlobalProperties
. https://github.com/mono/mono/blob/main/mcs/class/System/System.Net.NetworkInformation/UnixIPGlobalProperties.cs
[DllImport ("libc")]
static extern int getdomainname ([MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 1)] byte [] name, int len);
getdomainname
is added to Android bionic on Android API Level 26. https://android.googlesource.com/platform/prebuilts/ndk/+/refs/tags/ndk-r25/platform/sysroot/usr/include/unistd.h
#if __ANDROID_API__ >= 26
int getdomainname(char* __buf, size_t __buf_size) __INTRODUCED_IN(26);
int setdomainname(const char* __name, size_t __n) __INTRODUCED_IN(26);
#endif /* __ANDROID_API__ >= 26 */
CookieContainer
calls DomainName
. https://github.com/mono/mono/blob/main/mcs/class/referencesource/System/net/System/Net/cookiecontainer.cs
public CookieContainer() {
#if !WASM
string domain = IPGlobalProperties.InternalGetIPGlobalProperties().DomainName;
if (domain != null && domain.Length > 1)
{
m_fqdnMyDomain = '.' + domain;
}
#endif
//Otherwise it will remain string.Empty
}
If you can not set minimum API Level to 26, I think you can remove the code in #if
and recompile mscorlib.dll.
You can do this on PC and copy mscorlib.dll to Android device.
I have upgraded my mobile phone system from Android 7.1.1 to Android 9.0, and then it is normal.
Android 7.1 is API Level 25. This explains the problem.
I have a program in mono termux 6.12.0.122-arm64-android24. tar. XZ works normally, but switch to mono termux 6.12.0.122-armv7a-android21. tar. XZ, report an error.
Error content:
Unhandled Exception:
System. EntryPointNotFoundException: getdomainname assembly: type: member:(null)
at (wrapper managed-to-native) System. Net. NetworkInformation. CommonUnixIPGlobalProperties. getdomainname(byte[],int)
at System. Net. NetworkInformation. CommonUnixIPGlobalProperties. get_ DomainName () [0x0000b] in <49b03f92059344cc840103fd28261b35>:0
at System. Net. CookieContainer.. ctor () [0x0003f] in <49b03f92059344cc840103fd28261b35>:0
Code used: System.Net.CookieContainer cookieContainer = new System.Net.CookieContainer();
How can I repair it?