[Mono-devel-list] Default:ChangeType, MonoType, dynamically loaded assemblies and MonoCMethod:Invoke on constructors

Gary M. Smithrud gary.smithrud at haley.com
Thu Jun 16 19:55:09 EDT 2005


I have the following two assemblies that are being loaded dynamically
from within an application.  In the constructor for a class in the first
assembly, it has a parameter that is an instance of a class in the
second assembly.  When attempting to call the constructor for the first
class (using reflection), I get the exception "System.ArgumentException:
parameters" (by the way, this exception could really provide more
information or the outer one should so that way it is a little easier to
track the problem down).

Looking at the trace, it looks like the compile MonoType is different
than the MonoType for the same class when loading the assembly
dynamically (determined this by the tracing/debugging output).  The
application does not have access to the assemblies when it is built, nor
does it know the order in which they are loaded.  The first assembly
does reference the second one when it is built, of course.  In the
trace, the object that is passed in the array has the correct type, but
the type's are different when they are compared in Default:ChangeType (I
do not know what type Mono believes it is, because I have not been able
to get Mono-Develop to build.  I am not sure that I can get that
information from gdb either.)

The question is, "Has this been tested and the problem is in my code or
does Mono have an issue with this?"  Unfortunately, I am leaving town
tomorrow and do not have time right now to provide an example.  Below is
code that sort of shows the issue:

using B;
namespace A {
   public abstract class ClassA {
      ClassC _foo;	// In B.
      double _value;
      int number;
      public ClassA(ClassC foo, double value, int number) {
         _foo = _foo;
         _value = value;
         _number = number;
      }
   }
   public ClassB : ClassA {
      public ClassB(ClassC foo, double value, int number) :
base(foo,value,number) {
         // do whatever
      }
   }
}

namespace B {
   public ClassC {
   }
}

The exception occurs when you pass an instance of B.ClassC to the
constructor of ClassB.

Thanks for any information (again, I will be out of town until Tuesday,
if you have any questions),
Gary.




More information about the Mono-devel-list mailing list