vendredi 23 décembre 2016

Mono: CustomAttributeExtensions

I use the method GetCustomAttributes from the extension class CustomAttributeExtensions:

var serviceInterface = service.GetInterfaces().FirstOrDefault(i => i.GetCustomAttributes().Contains(new ServiceContractAttribute()));

When I run my application under mono 4.0 on debian I get the following exception:

Missing method GetCustomAttributes in assembly /root/mkmServer/MKMWatcher.Services.exe, type System.Reflection.CustomAttributeExtensions

Unhandled Exception: System.TypeLoadException: Could not load type 'System.Reflection.CustomAttributeExtensions' from assembly 'MKMWatcher.Services'.
  at System.Linq.Enumerable.First[Type] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
  at System.Linq.Enumerable.FirstOrDefault[Type] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
  at MKMWatcher.Services.ServiceManager.CreateService (System.Type service, System.String serviceAddress) [0x00000] in <filename unknown>:0
  at MKMWatcher.Services.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'System.Reflection.CustomAttributeExtensions' from assembly 'MKMWatcher.Services'.
  at System.Linq.Enumerable.First[Type] (IEnumerable`1 source, System.Func`2 predicate, Fallback fallback) [0x00000] in <filename unknown>:0
  at System.Linq.Enumerable.FirstOrDefault[Type] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
  at MKMWatcher.Services.ServiceManager.CreateService (System.Type service, System.String serviceAddress) [0x00000] in <filename unknown>:0
  at MKMWatcher.Services.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0

When I decompile the mscorlib.dll from mono which should contain the class I don't find it in his namespace:

enter image description here

But when I take a look at the mono github repository, the class is present: http://ift.tt/2hyyAz1

Do you know what's happening ? Are the assemblies deployed in the latest version of mono not reflecting... their source code ? The file haven't been touched for a while and it's not like it was a new feature... Any ideas ? Any solution that does not involve for me to get the latest mono source and compile them by hand ?

Thank you in advance for you answers.





Aucun commentaire:

Enregistrer un commentaire