3

I have a local webapi which i use a selfsigned certificate to run on a pc.I am able to reach the webapi (written in .net core) using the browser (https://localhost:port/controller/method), but when i use httpclient on Mac OS Mojave i get an exception (High Sierra and Catalina works).

System.DllNotFoundException: libc.dylib assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) System.Net.NetworkInformation.CommonUnixIPGlobalProperties.getdomainname(byte[],int)
  at System.Net.NetworkInformation.CommonUnixIPGlobalProperties.get_DomainName () [0x0000b] in <4b9a7f543fd447a3be5e54f34ee219b2>:0 
  at System.Net.CookieContainer..ctor () [0x0003f] in <4b9a7f543fd447a3be5e54f34ee219b2>:0 
  at System.Net.Http.MonoWebRequestHandler.get_CookieContainer () [0x0000a] in <e45d721af82a41d98156aeda80e9ce53>:0 
  at System.Net.Http.MonoWebRequestHandler.CreateWebRequest (System.Net.Http.HttpRequestMessage request) [0x000f5] in <e45d721af82a41d98156aeda80e9ce53>:0 
  at System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x0003e] in <e45d721af82a41d98156aeda80e9ce53>:0 
  at System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x000e8] in <e45d721af82a41d98156aeda80e9ce53>:0 
  at Mac_Installer.ViewController.Timer_Elapsed (System.Object sender, System.Timers.ElapsedEventArgs e) [0x000bd] in <3581d802103c47bbbf47f26a2763b24c>:0

I have read up and it seems like i need to set the DYLD_FALLBACK_LIBRARY_PATH to /usr/lib (I can see the file - libc.dylib - is there), believe i should add it in the info.plist as an environment variable, but it still fails, or i am doing it wrong.

Any help appreciciated.

JP Veldtman
  • 182
  • 1
  • 8
  • Take note, i've set it in Terminal aswell and it is still throwing an exception – JP Veldtman Jan 30 '20 at 14:25
  • On further investigation, if i copy libSystem.B.dylib over to the app MonoBundle or Resources folder and rename the file to libc.dylib it is working, but i don't want to embed a library file in the package – JP Veldtman Jan 31 '20 at 06:41

2 Answers2

2

If you enabled hardened runtime, try adding "Allow DYLD Environment Variables Entitlement" (com.apple.security.cs.allow-dyld-environment-variables) into your Entitlements.plist.

Jiri Volejnik
  • 1,034
  • 6
  • 9
0

I just copy libc.dylib. over to the app MonoBundle or Resources folder. The Dll can be found here: https://github.com/facilityweb/Dlls/blob/master/libc.dylib

Another Solution is import the lib MainClass, like follows:

 static class MainClass
{
    static void Main(string[] args)
    {
        //solved mojave notfound dll exception
        IntPtr p = Dlfcn.dlopen("/usr/lib/libc.dylib", 0);

        NSApplication.Init();
        NSApplication.SharedApplication.Delegate = new AppDelegate();
        NSApplication.Main(args);
    }
}
Igor Monteiro
  • 933
  • 1
  • 11
  • 29