Question on BindingSource and Explicit Interface Properties

J

JM

In an application I have an interface with methods and properties. The
interface is used on a Class (ie class MyClass : IMyClassA, IMyClassB). On a
windows form I define a BindingSource (_bindingMyClass) where I set the
DataSource property to the interface IMyClass.

Now when the MyClass object is instantiated I set the BindingSource to the
instance of the IMyClass interface (_MyClass)

_bindingMyClass.DataSource = this._MyClass;

If the implement of the MYClass class uses expliciit interface
specifications for the properties, I get and ArgumentException on the above
code setting the DataSource.

If the implementation of the MYClass IMyClass interface specification are
not explicit, the above line works.

My question is why? I thought the only difference between an explicit
interface and an "standard" interface is to allow a class to have more than
one interface specified and have each interface implementation be unique.

Thanks,
 
N

Nicholas Paldino [.NET/C# MVP]

JM,

I'm not surprized. The binding is looking at the publically accessible
members on the implementation type, not the interfaces that it implements.
The reason it works when you use implicit interface implementation is
because you have to declare those members as public for the implementation
to be performed.
 

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