SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Designer bug

Last post 08-16-2006 9:14 PM by GoMa. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 04-23-2006 6:02 PM

    Designer bug

    I had a bug with #develop 2 while trying to use the designer.
    My project consists of many forms accessing a firebird db. As the forms have common properties, I made an abstract class inherting from System.Windows.Forms.Form, in this abstract class I defined the common methods, and from this class, almost all the forms of the project inherit.

    The first problem is that sharp develop refuses to open any of my forms that inherit from the abstract class in the designer, and issues this error message:

    Error loading designer:

    System.ComponentModel.Design.Serialization.CodeDomSerializerException: The designer must create an instance of type 'MAG.CMAGMdiChild' but it cannot because the type is declared as abstract.
       at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager manager, String exceptionText, String helpLink)
       at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
       at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
       at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)


    MAG.CMAGMdiChild is the abstract class I told about. Unless I change the parent to System.Windows.Forms.Form I can't open the form in the designer.

    The second problem is that when I do the same thing with another form of the project (changing the Parent to Form) and trying to open it in the designer, #develop raises the following exception:

    .NET Version         : 2.0.50727.42
    OS Version           : Microsoft Windows NT 5.1.2600 Service Pack 2
    Current culture      : English (United States) (en-US)
    Working Set Memory   : 75492kb
    SharpDevelop Version : 2.0.0.1135

    Exception thrown:
    System.ArgumentException: Stream is not a valid resource file.
       at System.Resources.ResourceReader.ReadResources()
       at System.Resources.ResourceReader..ctor(String fileName)
       at ICSharpCode.FormsDesigner.Services.DesignerResourceService.ResourceStorage.GetReader() in c:\SharpDevelop\Corsavy\SharpDevelop\src\AddIns\DisplayBindings\FormsDesigner\Project\Src\Services\DesignerResourceService.cs:line 97
       at ICSharpCode.FormsDesigner.Services.DesignerResourceService.GetResourceReader(CultureInfo info) in c:\SharpDevelop\Corsavy\SharpDevelop\src\AddIns\DisplayBindings\FormsDesigner\Project\Src\Services\DesignerResourceService.cs:line 208
  • 04-23-2006 7:55 PM In reply to

    • nailor
    • Top 50 Contributor
    • Joined on 03-13-2006
    • Karlsruhe - Germany
    • Posts 45

    Re: Designer bug

    the problem with abstract base classes in the designer is know but cannot / will not be fixed. easiest 'workaround' is to make the methods virtual instead of abstract but i agree that it is rather a hack than a workaround as it renders the complete "abstract idea" useless...
    .
  • 08-16-2006 9:14 PM In reply to

    • GoMa
    • Top 25 Contributor
    • Joined on 04-12-2006
    • Posts 80

    Re: Designer bug

    I experienced the same issue so tried to find where this could be fixed. What is basically needed is to change the base type the CodeDOM serializer sees from the abstract class to the base of that abstract class so an instance could be created.
    I've used Reflector to see how this can be done. The problem is that CodeDomDesignerLoader.EnsureDocument is where the base type is found from the CodeCompileUnit, and it is private (not overridable). Maybe the compile unit can be changed in Parse to have the designed class derive from the first non-abstract class up the hierarchy?
    This might break other things (like Designer/RootDesigner attributes on the abstract base class), but I'm not really sure what the implications may be.
    I don't know much in this area, so I might be completely wrong.
    For what it's worth, Visual Studio does not handle this as well (shows same exception), but I think SharpDevelop should be able to handle it, and it should at least be added to the bug tracker. ;-)

Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.