MissingMethodException without Reflection, COM, DLLs, or anything else.

D

D. Bron

Hello,

Can anyone tell me why I'm getting the following exception:

Method not found:
Void Maple.Collections.Set.UnionAll(System.Collections.ICollection)

I'm not using reflection, I'm not using COM, and I'm not referencing
external DLLs (only other projects in the same solution). If this method
were really "missing", I would expect a build time error, not a run time
error. But my solution compiles fine, and even Intellisense shows me the
UnionAll method.

MSDN and Google have no answers. The most relevant thing I could find was
MSKB article 834063 (http://support.microsoft.com/?kbid=834063), which is
about COM objects (I tried implementing its solution anyway, by adding a
set accessor, but that didn't solve the problem).

So, if anyone can help, I would appreciate it. Here is the relevant code:

The exception occurs on the following line:

this.GrantedPermissions.Grant(r.GrantedPermissions);

Where both 'this.GrantedPermissions' and 'r.GrantedPermissions' are of type
'Maple.Security.PermissionSet : System.Collections.ICollection' which has
the following polymorphic definition for 'Grant':

public void Grant(Permission p)
{
this.ps.Union(p);
}
public void Grant(PermissionSet s)
{
this.ps.UnionAll(s);
}

Where 'this.ps' is of type 'Maple.Collections.Set', which has the following
two relevant definitions:

public void Union(object o)
{
if (! this.al.Contains(o))
{
this.al.Add(o);
}
}

public void UnionAll(System.Collections.ICollection s)
{
foreach(object o in s)
{
if(! this.al.Contains(o))
{
this.al.Add(o);
}
}
}

Where 'this.al' is of type System.Collections.ArrayList.

I'm using .NET Framework version 1.1. Maple.Security and Maple.Permissions
are in seperate assemblies, linked by am intra-solution a project
reference.

Note that if I rename 'UnionAll' to 'Union' (and thus make it a polymorphic
definition), I don't get the MissingMethodException, but the wrong overload
of Union is called (object o instead of System.Collections.ICollection s).

Thanks for any help,

-D. Bron
 
D

D. Bron

In lieu of either Union + UnionAll (which doesn't work), and polymorphism
(which doesn't work), I've redefined Union thus:


public void Union(object o)
{

if(!o.GetType().IsSubclassOf(typeof(System.Collections.ICollecti
on)))
{
if (! al.Contains(o))
{
this.al.Add(o);
}
}
else
{
System.Collections.ICollection s =
(System.Collections.ICollection) o;

foreach(object oo in s)
{
if(! this.al.Contains(oo))
{
this.al.Add(oo);
}
}

}
}

Not only does this not solve my problem, it causes even weirder effects.
For one thing, the line highlighting in debug mode is all off. When
stepping through it, blank lines and partial lines are highlighted. Also,
I never get into the 'else' branch; the 'if' branch is always chosen. When
I tried to debug this by changing:

if(!o.GetType().IsSubclassOf(typeof(System.Collections.ICollection)))

to
System.Type ot = o.GetType();
System.Type ct = typeof(System.Collections.ICollection);
if(!ot.IsSubclassOf(ct))

Then I cannot interrogate the values of 'ot' and 'ct' at debug time; I am
told they are 'out of scope' even though I'm within the definition of
Union.

Curiouser and Curiouser,

-D. Bron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top