HANDLE_FUNCTION_ENTER ();
MonoAssembly *ret = NULL;
MonoDomain *domain = mono_alc_domain (alc);
+ char *filename = NULL;
if (mono_runtime_get_no_exec ())
goto leave;
if (ret && !refonly && mono_asmctx_get_kind (&ret->context) == MONO_ASMCTX_REFONLY) {
/* .NET Framework throws System.IO.FileNotFoundException in this case */
- mono_error_set_file_not_found (error, NULL, "AssemblyResolveEvent handlers cannot return Assemblies loaded for reflection only");
+ filename = mono_string_handle_to_utf8 (fname, error);
+ mono_error_set_file_not_found (error, filename, "AssemblyResolveEvent handlers cannot return Assemblies loaded for reflection only: %s", filename);
ret = NULL;
goto leave;
}
#endif
leave:
+ g_free (filename);
HANDLE_FUNCTION_RETURN_VAL (ret);
}
if (!ass) {
if (status == MONO_IMAGE_IMAGE_INVALID)
- mono_error_set_bad_image_by_name (error, name, "Invalid Image");
+ mono_error_set_bad_image_by_name (error, name, "Invalid Image: %s", name);
else
- mono_error_set_file_not_found (error, name, "Invalid Image");
+ mono_error_set_simple_file_not_found (error, name, refOnly);
goto leave;
}
ass = mono_assembly_request_open (filename, &req, &status);
if (!ass) {
if (status == MONO_IMAGE_IMAGE_INVALID)
- mono_error_set_bad_image_by_name (error, filename, "Invalid Image");
+ mono_error_set_bad_image_by_name (error, filename, "Invalid Image: %s", filename);
else
- mono_error_set_file_not_found (error, filename, "Invalid Image");
+ mono_error_set_simple_file_not_found (error, filename, asmctx == MONO_ASMCTX_REFONLY);
}
leave:
mono_metadata_string_heap_checked (MonoImage *meta, guint32 index, MonoError *error)
{
if (G_UNLIKELY (!(index < meta->heap_strings.size))) {
- mono_error_set_bad_image_by_name (error, meta->name ? meta->name : "unknown image", "string heap index %ud out bounds %u", index, meta->heap_strings.size);
+ const char *image_name = meta && meta->name ? meta->name : "unknown image";
+ mono_error_set_bad_image_by_name (error, image_name, "string heap index %ud out bounds %u: %s", index, meta->heap_strings.size, image_name);
return NULL;
}
return meta->heap_strings.data + index;
if (G_UNLIKELY (index == 0 && meta->heap_blob.size == 0))
return NULL;
if (G_UNLIKELY (!(index < meta->heap_blob.size))) {
- mono_error_set_bad_image_by_name (error, meta->name ? meta->name : "unknown image", "blob heap index %u out of bounds %u", index, meta->heap_blob.size);
+ const char *image_name = meta && meta->name ? meta->name : "unknown image";
+ mono_error_set_bad_image_by_name (error, image_name, "blob heap index %u out of bounds %u: %s", index, meta->heap_blob.size, image_name);
return NULL;
}
return meta->heap_blob.data + index;
const char *image_name = image && image->name ? image->name : "unknown image";
if (G_UNLIKELY (! (idx < t->rows && idx >= 0))) {
- mono_error_set_bad_image_by_name (error, image_name, "row index %d out of bounds: %d rows", idx, t->rows);
+ mono_error_set_bad_image_by_name (error, image_name, "row index %d out of bounds: %d rows: %s", idx, t->rows, image_name);
return FALSE;
}
const char *data = t->base + idx * t->row_size;
if (G_UNLIKELY (res_size != count)) {
- mono_error_set_bad_image_by_name (error, image_name, "res_size %d != count %d", res_size, count);
+ mono_error_set_bad_image_by_name (error, image_name, "res_size %d != count %d: %s", res_size, count, image_name);
return FALSE;
}
case 4:
res [i] = read32 (data); break;
default:
- mono_error_set_bad_image_by_name (error, image_name, "unexpected table [%d] size %d", i, n);
+ mono_error_set_bad_image_by_name (error, image_name, "unexpected table [%d] size %d: %s", i, n, image_name);
return FALSE;
}
data += n;
return amodule->image_table [index];
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: module %s wants to load image %d: %s", amodule->aot_name, index, amodule->image_names[index].name);
if (amodule->out_of_date) {
- mono_error_set_bad_image_by_name (error, amodule->aot_name, "Image out of date");
+ mono_error_set_bad_image_by_name (error, amodule->aot_name, "Image out of date: %s", amodule->aot_name);
return NULL;
}
}
if (!assembly) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable because dependency %s is not found.", amodule->aot_name, amodule->image_names [index].name);
- mono_error_set_bad_image_by_name (error, amodule->aot_name, "module is unusable because dependency %s is not found (error %d).\n", amodule->image_names [index].name, status);
+ mono_error_set_bad_image_by_name (error, amodule->aot_name, "module '%s' is unusable because dependency %s is not found (error %d).\n", amodule->aot_name, amodule->image_names [index].name, status);
amodule->out_of_date = TRUE;
return NULL;
}
if (strcmp (assembly->image->guid, amodule->image_guids [index])) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s')).", amodule->aot_name, amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
- mono_error_set_bad_image_by_name (error, amodule->aot_name, "module is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s')).", amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
+ mono_error_set_bad_image_by_name (error, amodule->aot_name, "module '%s' is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s')).", amodule->aot_name, amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
amodule->out_of_date = TRUE;
return NULL;
}
reftype = decode_value (p, &p);
if (reftype == 0) {
*endbuf = p;
- mono_error_set_bad_image_by_name (error, module->aot_name, "Decoding a null class ref");
+ mono_error_set_bad_image_by_name (error, module->aot_name, "Decoding a null class ref: %s", module->aot_name);
return NULL;
}
token = decode_value (p, &p);
image = module->assembly->image;
if (!image) {
- mono_error_set_bad_image_by_name (error, module->aot_name, "No image associated with the aot module");
+ mono_error_set_bad_image_by_name (error, module->aot_name, "No image associated with the aot module: %s", module->aot_name);
return NULL;
}
klass = mono_class_get_checked (image, token, error);
break;
}
default:
- mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid klass reftype %d", reftype);
+ mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid klass reftype %d: %s", reftype, module->aot_name);
}
//g_assert (klass);
//printf ("BLA: %s\n", mono_type_full_name (m_class_get_byval_arg (klass)));
break;
}
default:
- mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid encoded type %d", t->type);
+ mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid encoded type %d: %s", t->type, module->aot_name);
goto fail;
}
else if (wrapper_type == MONO_WRAPPER_STFLD)
ref->method = mono_marshal_get_stfld_wrapper (type);
else {
- mono_error_set_bad_image_by_name (error, module->aot_name, "Unknown AOT wrapper type %d", wrapper_type);
+ mono_error_set_bad_image_by_name (error, module->aot_name, "Unknown AOT wrapper type %d: %s", wrapper_type, module->aot_name);
return FALSE;
}
break;
if (!ref->method)
ref->method = mono_gc_get_managed_allocator_by_type (atype, MANAGED_ALLOCATOR_SLOW_PATH);
if (!ref->method) {
- mono_error_set_bad_image_by_name (error, module->aot_name, "Error: No managed allocator, but we need one for AOT.\nAre you using non-standard GC options?\n");
+ mono_error_set_bad_image_by_name (error, module->aot_name, "Error: No managed allocator, but we need one for AOT.\nAre you using non-standard GC options?\n%s\n", module->aot_name);
return FALSE;
}
break;
return FALSE;
}
} else {
- mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid STELEMREF subtype %d", subtype);
+ mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid STELEMREF subtype %d: %s", subtype, module->aot_name);
return FALSE;
}
break;
guint32 init_type = decode_value (p, &p);
ref->method = mono_marshal_get_llvm_func_wrapper ((MonoLLVMFuncWrapperSubtype) init_type);
} else {
- mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid UNKNOWN wrapper subtype %d", subtype);
+ mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid UNKNOWN wrapper subtype %d: %s", subtype, module->aot_name);
return FALSE;
}
break;
else if (subtype == WRAPPER_SUBTYPE_ISINST_WITH_CACHE)
ref->method = mono_marshal_get_isinst_with_cache ();
else {
- mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid CASTCLASS wrapper subtype %d", subtype);
+ mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid CASTCLASS wrapper subtype %d: %s", subtype, module->aot_name);
return FALSE;
}
break;
return_val_if_nok (error, FALSE);
break;
default:
- mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid METHODREF_ARRAY method type %d", method_type);
+ mono_error_set_bad_image_by_name (error, module->aot_name, "Invalid METHODREF_ARRAY method type %d: %s", method_type, module->aot_name);
return FALSE;
}
} else {
if (ref.method)
return ref.method;
if (!ref.image) {
- mono_error_set_bad_image_by_name (error, module->aot_name, "No image found for methodref with target");
+ mono_error_set_bad_image_by_name (error, module->aot_name, "No image found for methodref with target: %s", module->aot_name);
return NULL;
}
return mono_get_method_checked (ref.image, ref.token, NULL, NULL, error);