Bug 32882 - MethodRental.SwapMethodBody throws not implemented exception
Summary: MethodRental.SwapMethodBody throws not implemented exception
Alias: None
Product: Installers
Classification: Mono
Component: General ()
Version: 4.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
Depends on:
Reported: 2015-08-07 15:24 UTC by softlion
Modified: 2015-08-08 10:25 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 softlion 2015-08-07 15:24:15 UTC

        private void OverrideSomeMethod()
            var replacedMethod = typeof(String).GetMethod("Intern", BindingFlags.Public | BindingFlags.Static);
            var newMethod = typeof(StringEx).GetMethod("Intern", BindingFlags.Public | BindingFlags.Static);
            var pNewMethod = newMethod.MethodHandle.GetFunctionPointer();

            MethodRental.SwapMethodBody(typeof(String), replacedMethod.MetadataToken, pNewMethod, newMethod.GetMethodBody().GetILAsByteArray().Length, MethodRental.JitOnDemand);

public static class StringEx {
    public static string Intern(string str)
  return null;
Comment 1 Rodrigo Kumpera 2015-08-07 18:53:26 UTC

MethodRental is not currently supported by Xamarin.

We don't have immediate plans to implement it but I would love to hear about your need for it so we could adjust our internal roadmap.
Comment 2 softlion 2015-08-08 03:22:10 UTC
I'm hacking into Xamarin Forms (Android) implementation so it supports a FileImageSource coming from any filesystem path instead of only the "Drawable" bundle folder (when used in ToolbarItems).

I have managed to do it by reflection instead.

FileImageSource on iOS for ToolbarItems already supports files coming from any filesystem path.

I needed that because i'm using svg images that are resolution independant and don't fit into the Drawable folder or as a bundle resource. Look at the latest XamSvg implementation on my nuget server.

Anyway ty for the answer!
Comment 3 Rodrigo Kumpera 2015-08-08 10:25:48 UTC

You might be interested on this XF limitation.