Bug 4633 - Type.GetMethods throws an exception if the type is a class that implements an interface
Summary: Type.GetMethods throws an exception if the type is a class that implements an...
Status: RESOLVED NORESPONSE
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-04-25 02:24 UTC by Dylan Borg
Modified: 2016-02-15 18:09 UTC (History)
4 users (show)

Tags:
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:
Status:
RESOLVED NORESPONSE

Description Dylan Borg 2012-04-25 02:24:09 UTC
I tried calling Type.GetMethods on a type representing a class 'HelloClass' which implements an interface 'IHello' that has a method 'Hello'. The methods throws an exception with 'managed-to-native' being present in the exception.
Here is an excerpt:

Unhandled Exception: System.TypeLoadException: Could not load type 'template.HelloClass' from assembly 'template, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'.
  at (wrapper managed-to-native) System.MonoType:GetMethodsByName (System.MonoType,string,System.Reflection.BindingFlags,bool,System.Type)
  at System.MonoType.GetMethods (BindingFlags bindingAttr) [0x00000] in <filename unknown>:0 
  at System.Type.GetMethods () [0x00000] in <filename unknown>:0 
  at dylan.NET.Reflection.Loader.LoadSpecMtds (System.Type typ) [0x00000] in <filename unknown>:0 
  at dylan.NET.Reflection.Loader.LoadConvOp (System.Type typ, System.String name, System.Type src, System.Type snk) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Helpers.EmitConv (System.Type source, System.Type sink) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Evaluator.ASTEmitIdent (dylan.NET.Tokenizer.AST.Tokens.Ident idt, Boolean emt, dylan.NET.Tokenizer.CodeGen.ASTEmitDelegate aed) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Evaluator.ASTEmit (dylan.NET.Tokenizer.AST.Tokens.Token tok, Boolean emt) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Evaluator.Evaluate (dylan.NET.Tokenizer.AST.Exprs.Expr exp) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Evaluator.StoreEmit (dylan.NET.Tokenizer.AST.Tokens.Token tok, dylan.NET.Tokenizer.AST.Exprs.Expr exp) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.StmtReader.Read (dylan.NET.Tokenizer.AST.Stmts.Stmt stm, System.String fpath) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.CodeGenerator.EmitMSIL (dylan.NET.Tokenizer.AST.Stmts.StmtSet stmts, System.String fpath) [0x00000] in <filename unknown>:0 
  at dylan.NET.Compiler.Module1.main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'template.HelloClass' from assembly 'template, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'.
  at (wrapper managed-to-native) System.MonoType:GetMethodsByName (System.MonoType,string,System.Reflection.BindingFlags,bool,System.Type)
  at System.MonoType.GetMethods (BindingFlags bindingAttr) [0x00000] in <filename unknown>:0 
  at System.Type.GetMethods () [0x00000] in <filename unknown>:0 
  at dylan.NET.Reflection.Loader.LoadSpecMtds (System.Type typ) [0x00000] in <filename unknown>:0 
  at dylan.NET.Reflection.Loader.LoadConvOp (System.Type typ, System.String name, System.Type src, System.Type snk) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Helpers.EmitConv (System.Type source, System.Type sink) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Evaluator.ASTEmitIdent (dylan.NET.Tokenizer.AST.Tokens.Ident idt, Boolean emt, dylan.NET.Tokenizer.CodeGen.ASTEmitDelegate aed) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Evaluator.ASTEmit (dylan.NET.Tokenizer.AST.Tokens.Token tok, Boolean emt) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Evaluator.Evaluate (dylan.NET.Tokenizer.AST.Exprs.Expr exp) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.Evaluator.StoreEmit (dylan.NET.Tokenizer.AST.Tokens.Token tok, dylan.NET.Tokenizer.AST.Exprs.Expr exp) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.StmtReader.Read (dylan.NET.Tokenizer.AST.Stmts.Stmt stm, System.String fpath) [0x00000] in <filename unknown>:0 
  at dylan.NET.Tokenizer.CodeGen.CodeGenerator.EmitMSIL (dylan.NET.Tokenizer.AST.Stmts.StmtSet stmts, System.String fpath) [0x00000] in <filename unknown>:0 
  at dylan.NET.Compiler.Module1.main (System.String[] args) [0x00000] in <filename unknown>:0 

I was using Mono 2.11 and 2.11.1 which both show this behavior.
Comment 1 Dylan Borg 2012-04-25 02:24:57 UTC
Please also note that teh assembly I was reflecting on was an AssemblyBuilder.
Comment 2 Dylan Borg 2012-04-25 06:34:27 UTC
Confirmed on 2.10.8 as well.
Comment 3 Rodrigo Kumpera 2013-01-11 16:50:59 UTC
Please provide a test case.
Comment 4 marcos.henrich 2016-02-15 18:09:28 UTC
Closing this bug report, if anyone is getting a similar issue please provide a test case so we can look into it.