C# 2.0 RTM compler incompatability with c# 1.1

I have an existing application that declares a class that derives from System.Windows.Forms.Form and an interface. This compiled and worked correctly in 1.1 but an error is reported during in C# 2.0 "IRecitalMirageForm - type is not supported by the language"

public class Form1 : System.Windows.Forms.Form, IRecitalMirageForm

Is there any workaround for this behavior



Answer this question

C# 2.0 RTM compler incompatability with c# 1.1

  • ChristopherK

    IRecitalMirageForm is an interface in my library.

    The C# 2.0 compiler will not allow me to apply an interface when i am subclassing a Form.

    This works perfectly ok in 1.1

    The interface is simple. It would appear that the C# 2.0 compiler only allows to subclass one class (as previously) but interfaces are in fact valid. For some reason it thinks the interface is also a class.

    The code for the interface is written in J#:

    package Recital.Mirage;
    public interface IRecitalMirageForm
    {
    public IRecitalMirage Mirage = null;
    public void OpenForm();
    public void CloseForm();
    public System.Collections.Hashtable GetForm();
    public void PutForm();
    }


    Maybe C# 2.0 does not handle j# interfaces correctly as it previously did.


  • melinjo

    I just added an interface to a subclassed Form, not a worry in the world.  I didn't use J#, however.  Why would you define the interface in J#, can J# also be used by Java or something

    If it's just an interface, how does it help to have it in J# Why can't you do it in C#


  • Wil Herren

    Well all compilers generate code that will run under the CLR.

    We happen to write in both J# and C# targetting the CLR.

    The problem appears to be in subclassing a J# interface with another class.

    Seeing that the interface is quite small it can easily be put into C#. The only point i am making however is that C# 2.0 has broken the previous behavior of 1.1 which handles this ok.

    Thanks for your feedback.



  • SED

    Barry,

    Thank you very much for sharing your issue.

    I am puzzled, not by the error you get but by it previously working! Please, if you have not already done so, file a bug in our product center with a repro also of the previous working code, so that we can investigate the difference and get back to you.

    Thanks again,

    Mads



  • Stefano.Gallotta

    I can't say that I have ever used J# before, however that interface definition you have posted would not be valid in C# as it has a field, C# prevents interfaces from having fields (I'm not sure if this is a CLR limitation, by the look at your definition perhaps not).

    If C# 1.1 allowed this same declaration, post a bug on the Microsoft Product Feedback Center with example projects both in Visual Studio 2003 and Visual Studio 2005.

  • Adam81

    I would recommend you to only expose CLS compliant types/interfaces if you want to be able to use multiple languages. Having fields in interfaces is (as mentioned above) not CLS compliant, which means that other CLS compliant languages (i.e. C#, VB) may not be able to use the interface.

    Best regards,
    Johan Stenberg

  • shiuu

    IRecitalMirageForm is not a .NET defined namespace, it must be something you're defining yourself, or that is defined by a library that you're using.  Perhaps it was visible in .NET 1.1 and for some reason your code in .NET 2.0 has changed so that it's no longer visible to this class

    In fact, I googled and could not find it at all, so I'd bet on it being in your code base somewhere.  As the interface is not part of the framework, it's not a .NET problem, I'm sure you can still apply an interface to a class in .NET 2.0.


  • PaulTromans

    David, I take back what I said earlier. It is a nuisance to have to recode the interface in C# as the assembly containing it can only use one language even in VS 2005 you cannot include J# and C# classes into the same assembly. This means we would have to create a C# assembly from a C# project just to hold the interface.

    I will report the incompability as this all works perfectly well in 1.1.

    Thanks again.

  • C# 2.0 RTM compler incompatability with c# 1.1