0

I've used ILRepack to merge a bunch of DLLs into a final Merged.dll with

ILRepack.exe /verbose /out:C:\..\.Merged.dll /wildcards *.dll /lib:C:\.MonoAndroidPath.\v8.1

Some of the merged DLLs use Mono.Android.dll functionality and I do not want to merge that in as I believe it to be wrong and also the output assembly will go at ~30MB.

That's why instead of merging it I used the /lib feature of ILRepack to specify a reference. /lib:C:\.MonoAndroidPath.\v8.1 is the path to the Mono.Android.dll also used by the xamarin solution.

When I use the Merged.dll in the app, it does compile but when the app is about to start I get

Java.Lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

Is there any way to solve this?

The solution does work if all of the DLLs are added separately.

Edit:

java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation getting while running test project?

I did read through this post and similar ones, but they relate to an Android solution and not to a Xamarin solution. I couldn't translate so far the solution provided there to my case. So please do not close this question as it is still relevant.

Stefan
  • 17,448
  • 11
  • 60
  • 79
Bogdan Daniel
  • 2,689
  • 11
  • 43
  • 76
  • Possible duplicate of [java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation getting while running test project?](https://stackoverflow.com/questions/11155340/java-lang-illegalaccesserror-class-ref-in-pre-verified-class-resolved-to-unexpe) – Stefan Aug 22 '18 at 07:15
  • @Stefan did read around that post, but it has to do more with an Android solution and not a Xamarin one. I did not find a way to solve it by translating what was being discussed there in C# – Bogdan Daniel Aug 22 '18 at 07:17
  • Hmm.. yes, I see. Nevertheless, the error seems to indicate that there is a duplicate reference. Can you verify that? – Stefan Aug 22 '18 at 07:22
  • It does indicate that, and in theory it might be as I'm not fully aware of what the `/lib` functionality of ILRepack does. The Xamarin.Android solution does have a reference to the Mono.Android.dll project as mentioned in the post, but the same path to that reference is defined in the `/lib` command. What I believe to be the solution is to somehow specify in the .csproj that the first working reference to the Mono.Android.dll found to be the one used, but haven't found a way to do that so far. – Bogdan Daniel Aug 22 '18 at 07:25

0 Answers0