469,898 Members | 1,836 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

Question on BindingSource and Explicit Interface Properties

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,

Dec 6 '07 #1
1 3037
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"JM" <JM@discussions.microsoft.comwrote in message
news:6E**********************************@microsof t.com...
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,
Dec 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by george r smith | last post: by
9 posts views Thread by davetelling | last post: by
3 posts views Thread by Przemek M. Zawada | last post: by
1 post views Thread by Frank Rizzo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.