[Mono-bugs] [Bug 636939] New: cannot invoke three argument version of String.Format via Reflection

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Sep 3 04:38:06 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=636939

https://bugzilla.novell.com/show_bug.cgi?id=636939#c0


           Summary: cannot invoke three argument version of String.Format
                    via Reflection
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: x86
        OS/Version: Windows 7
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: joe at mistachkin.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8)
Gecko/20100722 Firefox/3.6.8

using System;
using System.Globalization;
using System.Reflection;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            CultureInfo cultureInfo = CultureInfo.CurrentCulture;

            BindingFlags bindingFlags =
                BindingFlags.IgnoreCase | BindingFlags.Instance |
                BindingFlags.Static | BindingFlags.Public |
                BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod;

            Console.WriteLine(typeof(String).InvokeMember(
                "format", bindingFlags, null, null,
                new object[] { cultureInfo, "{0:X2}", 1234 }));

            Console.ReadKey();
        }
    }
}


Reproducible: Always

Steps to Reproduce:
1. Compile and run the above code.

Actual Results:  
Mono throws the following exception:

Unhandled Exception: System.MissingMethodException: The best match for method
format has some invalid parameter.
  at System.MonoType.InvokeMember (System.String name, BindingFlags invokeAttr,
System.Reflection.Binder binder, System.Object target, System.Object[] args,
System.Reflection.ParameterModifier[] modifiers,
System.Globalization.CultureInfo culture, System.String[] namedParameters)
[0x00000] in <filename unknown>:0
  at System.Type.InvokeMember (System.String name, BindingFlags invokeAttr,
System.Reflection.Binder binder, System.Object target, System.Object[] args)
[0x00000] in <filename unknown>:0
  at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in
<filename unknown>:0

Expected Results:  
The string "4D2" should be written to the console.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list