#include <mono/metadata/mono-ptr-array.h>
#include <mono/metadata/verify-internals.h>
#include <mono/metadata/runtime.h>
+#include <mono/metadata/file-mmap.h>
#include <mono/io-layer/io-layer.h>
#include <mono/utils/strtod.h>
#include <mono/utils/monobitset.h>
static MonoReflectionType *
type_from_name (const char *str, MonoBoolean ignoreCase)
{
+ MonoMethod *m, *dest;
+
MonoType *type = NULL;
MonoAssembly *assembly = NULL;
MonoTypeNameParse info;
return NULL;
}
- if (info.assembly.name) {
- assembly = mono_assembly_load (&info.assembly, NULL, NULL);
- } else {
- MonoMethod *m = mono_method_get_last_managed ();
- MonoMethod *dest = m;
- mono_stack_walk_no_il (get_caller_no_reflection, &dest);
- if (!dest)
- dest = m;
+ /*
+ * We must compute the calling assembly as type loading must happen under a metadata context.
+ * For example. The main assembly is a.exe and Type.GetType is called from dir/b.dll. Without
+ * the metadata context (basedir currently) set to dir/b.dll we won't be able to load a dir/c.dll.
+ */
+ m = mono_method_get_last_managed ();
+ dest = m;
- /*
- * FIXME: mono_method_get_last_managed() sometimes returns NULL, thus
- * causing ves_icall_System_Reflection_Assembly_GetCallingAssembly()
- * to crash. This only seems to happen in some strange remoting
- * scenarios and I was unable to figure out what's happening there.
- * Dec 10, 2005 - Martin.
- */
+ mono_stack_walk_no_il (get_caller_no_reflection, &dest);
+ if (!dest)
+ dest = m;
- if (dest) {
- assembly = dest->klass->image->assembly;
- type_resolve = TRUE;
- } else {
- g_warning (G_STRLOC);
- }
+ /*
+ * FIXME: mono_method_get_last_managed() sometimes returns NULL, thus
+ * causing ves_icall_System_Reflection_Assembly_GetCallingAssembly()
+ * to crash. This only seems to happen in some strange remoting
+ * scenarios and I was unable to figure out what's happening there.
+ * Dec 10, 2005 - Martin.
+ */
+
+ if (dest) {
+ assembly = dest->klass->image->assembly;
+ type_resolve = TRUE;
+ } else {
+ g_warning (G_STRLOC);
}
+ if (info.assembly.name)
+ assembly = mono_assembly_load (&info.assembly, assembly ? assembly->basedir : NULL, NULL);
+
+
if (assembly) {
/* When loading from the current assembly, AppDomain.TypeResolve will not be called yet */
type = mono_reflection_get_type (assembly->image, &info, ignoreCase, &type_resolve);
ICALL_EXPORT void
ves_icall_System_Environment_InternalSetEnvironmentVariable (MonoString *name, MonoString *value)
{
- MonoError error;
#ifdef HOST_WIN32
-
gunichar2 *utf16_name, *utf16_value;
#else
gchar *utf8_name, *utf8_value;
+ MonoError error;
#endif
MONO_ARCH_SAVE_REGS;
ves_icall_System_Environment_BroadcastSettingChange (void)
{
#ifdef HOST_WIN32
- SendMessageTimeout (HWND_BROADCAST, WM_SETTINGCHANGE, NULL, L"Environment", SMTO_ABORTIFHUNG, 2000, 0);
+ SendMessageTimeout (HWND_BROADCAST, WM_SETTINGCHANGE, (WPARAM)NULL, (LPARAM)L"Environment", SMTO_ABORTIFHUNG, 2000, 0);
#endif
}