我有一个本地webapi,我使用一个自签名的证书在Mac上运行,我能够使用浏览器(https://localhost:port/controller/method)到达webapi (用https://localhost:port/controller/method编写),但是当我在Mojave上使用httpclient时,我会得到一个异常()。
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我已经阅读过了,似乎需要将DYLD_FALLBACK_LIBRARY_PATH设置为/usr/lib (我可以看到文件-- libc.dylib ),相信我应该将它作为环境变量添加到info.plist中,但它仍然失败,否则我做错了。
任何帮助都可以。
发布于 2020-02-07 12:14:40
如果启用了强化运行时,请尝试将“允许DYLD环境变量权限”(com.apple.security.cs.allow-dyld-environment-variables)添加到Entitlements.plist中。
发布于 2020-04-06 22:35:15
我只是复制libc.dylib。转到应用程序MonoBundle或参考资料文件夹。Dll可以在这里找到:https://github.com/facilityweb/Dlls/blob/master/libc.dylib
另一个解决方案是导入库MainClass,如下所示:
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);
}
}https://stackoverflow.com/questions/59986429
复制相似问题