views:

72

answers:

1

I'm working with .NET Compact Framework and just started to refactor some UI code. I'm defining a base user control to encapsulate common functionality, the project compiles OK but when I try to open a child user control in design mode I'm getting an error.

I made my class hierarchy taking into account this question. My classes are like this:

//on the data layer..
interface IDataObject {}
class Foo: IDataObject {}

//on the UI layer i have
class BaseDataUserControl<TDataObject> : UserControl 
where TDataObject : IDataObject {}

class FooUserControl : BaseDataUserControl<Foo> {}

This is the error I'm getting:

GenericArguments[0], 'Foo', on 'BaseDataUserControl`1[TDataObject]' violates the constraint of type 'TDataObject'

Can anyone point out to me why this does not work?

+1  A: 

This has to be an ambiguity problem, the compiler sees a different definition of IDataObject when compiling FooUserControl. Which is easy to do, the System.Windows.Forms namespace already has an IDataObject interface.

Pick a different name or type the full namespace name.

Hans Passant
Ok i renamed the class as you suggested and still did not work, so what i just did was to reboot my computer (horay for random ideas!) , after that i managed to get the visual editor to display my user control =), ...sad thing though =(
Harima555