@@ -1177,7 +1177,7 @@ legacy_probe_for_module_relative_directories (MonoImage *image, const char *file
1177
1177
}
1178
1178
1179
1179
static MonoDl *
1180
- legacy_probe_for_module (MonoImage * image , const char * new_scope )
1180
+ legacy_probe_for_module (MonoImage * image , const char * new_scope , char * * load_error )
1181
1181
{
1182
1182
char * full_name , * file_name ;
1183
1183
char * error_msg = NULL ;
@@ -1202,7 +1202,8 @@ legacy_probe_for_module (MonoImage *image, const char *new_scope)
1202
1202
1203
1203
if (mono_get_find_plugin_callback ())
1204
1204
{
1205
- const char * unity_new_scope = mono_get_find_plugin_callback () (new_scope );
1205
+ gboolean hasError = FALSE;
1206
+ const char * unity_new_scope = mono_get_find_plugin_callback () (new_scope , & hasError );
1206
1207
if (unity_new_scope == NULL || !unity_new_scope [0 ])
1207
1208
{
1208
1209
mono_trace (G_LOG_LEVEL_WARNING , MONO_TRACE_DLLIMPORT ,
@@ -1212,6 +1213,9 @@ legacy_probe_for_module (MonoImage *image, const char *new_scope)
1212
1213
1213
1214
else
1214
1215
new_scope = g_strdup (unity_new_scope );
1216
+
1217
+ if (hasError )
1218
+ * load_error = mono_dl_current_error_string ();
1215
1219
}
1216
1220
1217
1221
/*
@@ -1280,7 +1284,7 @@ legacy_probe_for_module (MonoImage *image, const char *new_scope)
1280
1284
}
1281
1285
1282
1286
static MonoDl *
1283
- legacy_lookup_native_library (MonoImage * image , const char * scope )
1287
+ legacy_lookup_native_library (MonoImage * image , const char * scope , char * * load_error )
1284
1288
{
1285
1289
MonoDl * module = NULL ;
1286
1290
gboolean cached = FALSE;
@@ -1294,7 +1298,7 @@ legacy_lookup_native_library (MonoImage *image, const char *scope)
1294
1298
cached = TRUE;
1295
1299
1296
1300
if (!module )
1297
- module = legacy_probe_for_module (image , scope );
1301
+ module = legacy_probe_for_module (image , scope , load_error );
1298
1302
1299
1303
if (module && !cached ) {
1300
1304
mono_trace (G_LOG_LEVEL_DEBUG , MONO_TRACE_DLLIMPORT ,
@@ -1330,6 +1334,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou
1330
1334
const char * orig_scope = NULL ;
1331
1335
const char * new_scope = NULL ;
1332
1336
char * error_msg = NULL ;
1337
+ char * load_error = NULL ;
1333
1338
MonoDl * module = NULL ;
1334
1339
gpointer addr = NULL ;
1335
1340
@@ -1427,7 +1432,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou
1427
1432
flags = 0 ;
1428
1433
module = netcore_lookup_native_library (alc , image , new_scope , flags );
1429
1434
#else
1430
- module = legacy_lookup_native_library (image , new_scope );
1435
+ module = legacy_lookup_native_library (image , new_scope , & load_error );
1431
1436
#endif // ENABLE_NETCORE
1432
1437
1433
1438
if (!module ) {
@@ -1436,7 +1441,14 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou
1436
1441
new_scope );
1437
1442
1438
1443
status_out -> err_code = LOOKUP_PINVOKE_ERR_NO_LIB ;
1439
- status_out -> err_arg = g_strdup (new_scope );
1444
+ if (load_error != NULL && load_error [0 ])
1445
+ {
1446
+ status_out -> err_arg = g_strdup (load_error );
1447
+ }
1448
+ else
1449
+ {
1450
+ status_out -> err_arg = g_strdup (new_scope );
1451
+ }
1440
1452
goto exit ;
1441
1453
}
1442
1454
@@ -1463,6 +1475,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou
1463
1475
g_free ((char * )new_import );
1464
1476
g_free ((char * )new_scope );
1465
1477
g_free (error_msg );
1478
+ g_free (load_error );
1466
1479
return addr ;
1467
1480
}
1468
1481
0 commit comments