1

I have a problem: it seems like there is a bug or something in the .NET Framework 3.5. For example, consider the code below:

public interface IListModel
{
    Object Selected { get; set; }
}

// And then I define a class:

class ListModel <T> : IListModel where T : class
{
    Object IListModel.Selected
    {
        get
        {
            return Selected;
        }
        set
        {
            Selected = value as T;
        }
    }

    private T _selected;

    public virtual T Selected
    {
        get { return default (T); }
        set
        {
            _selected = value;
        }
    }
}

public interface IDummy : IListModel
{

}

// Then I define this class:
public class RadioGroupModel : ListModel<string>, IDummy
{
    public override string Selected
    {
        get
        {
            return base.Selected;
        }
        set
        {
            base.Selected = value;
        }
    }
}

If I run:

typeof (RadioGroupModel).GetProperty ("Selected", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); 

on some machines I receive an AmbiguousMatchException. On my computer it works like a charm. Note that the target framework is .NET Framework 3.5 Full. Any idea what is happening?

Whymarrh
  • 13,139
  • 14
  • 57
  • 108
George Lica
  • 1,798
  • 1
  • 12
  • 23
  • 1
    Clearly a conflict between the two `Selected` properties, but what is interesting is that it doesn't work the same on various machines. You should find out more about the differences between machines (all different framework versions installed on each, plus their bitness). – Medinoc Sep 01 '14 at 16:04

0 Answers0