Bug 16487 - Assembly.CreateInstance doesn't calls AssemblyResolve if assembly not found.
Summary: Assembly.CreateInstance doesn't calls AssemblyResolve if assembly not found.
Alias: None
Product: Runtime
Classification: Mono
Component: Reflection ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
Depends on:
Reported: 2013-11-27 20:51 UTC by Alistair Leslie-Hughes
Modified: 2013-12-06 13:40 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

Sample Program (1.75 KB, text/plain)
2013-11-27 20:51 UTC, Alistair Leslie-Hughes

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Alistair Leslie-Hughes 2013-11-27 20:51:45 UTC
Created attachment 5557 [details]
Sample Program

The attach program throws an exception instead of using AppDomain.AssemblyResolve to find the assembly.
Comment 1 Marek Safar 2013-12-05 05:23:12 UTC
There seems to be some loaded condition which does not trigger the event

Simple sample

using System;
using System.Reflection;
using System.Reflection.Emit;

class Test
	public static void Main ()
		AppDomain currentDomain = AppDomain.CurrentDomain;
		currentDomain.AssemblyResolve += new ResolveEventHandler (MyResolveEventHandler);
		Assembly.Load ("MyDynamicType,, Culture=neutral, PublicKeyToken=0738eb9f132ed756");

	static Assembly MyResolveEventHandler (object sender, ResolveEventArgs args)
		Console.WriteLine ("resolve");
		return null;
Comment 2 Alistair Leslie-Hughes 2013-12-05 05:32:13 UTC
The should have the "Version=" before it.
Comment 3 Marek Safar 2013-12-05 06:02:48 UTC
The event should be called even for invalid assembly name (that's probably the reason why it's failing)
Comment 4 Zoltan Varga 2013-12-06 13:40:10 UTC
Fixed in master.