Bug 10389 - Missing Method Exception when Activator.CreateInstance on constructor with 'ref'
Summary: Missing Method Exception when Activator.CreateInstance on constructor with 'ref'
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: unspecified
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-02-18 15:49 UTC by John Yost
Modified: 2013-02-20 15:11 UTC (History)
3 users (show)

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

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 John Yost 2013-02-18 15:49:20 UTC
Description of Problem: When creating an instance of an object where the constructor requires a 'ref' argument, I get a Missing Method Exception stating a method could not be found that matches.
The same code runs ok in Windows even though I'm not passing in a ref.

I suspect the same problem would occur with InvokeMethod too but haven't tried.

Steps to reproduce the problem:
1. Call Activator.CreateInstance(type, new object[] { notAref }) on an object requiring a 'ref' argument.

Actual Results:
Missing Method Exception

Expected Results:
No exception.  Expecting same behavior as non-mono based application.

How often does this happen?  It's consistent (100% of the time).

Additional Information:

Here's some code snippets for clarity...

public MyConstructor(ref SomeType data) {...
SomeType foo = new SomeType();
object handle = Activator.CreateInstance(typeof(MyConstructor), new object[] { st });
Comment 1 Marek Safar 2013-02-20 05:14:38 UTC
I cannot reproduce the issue with Mono 3.0.4

My full tests

using System;

class C
	public static void Main ()
		int v = 9;
		object handle = Activator.CreateInstance (typeof (GG), new object[] { v });

class GG
	public GG(ref int data)
		Console.WriteLine ("aa");
Comment 2 John Yost 2013-02-20 13:18:29 UTC
I'm running 2.6.7 on Linux.  Could this have been fixed between 2.6.7 and 3.0.4?
Comment 3 Marek Safar 2013-02-20 15:11:26 UTC
Yes, that's very likely