none
Windows.Forms base class in a separate assembly - Designer executes Form.Load event code RRS feed

  • Question

  • Hello,

    i create a separate assembly, and create a WinForms (base) class.
    Then i create an application which references to this assembly. In this application i create a WinForm which inherit from the base WinForm of the separate assembly.

    If i now open the designer of the application's WinForm the Load event code gets executed!
    For example: If i put a MessageBox.Show() in the Load event of the base WinForms (in the separate assembly) - i get this messagebox at design time!

    As far as i understand the designer reflects the InitializeComponents function, but does not execute it (or executes its events Oo).

    Like this i can't work with base assemblies..

    Greetings
    Yannik

    • Moved by Bob Ding Monday, August 14, 2017 6:15 AM
    Thursday, August 3, 2017 10:07 AM

All replies

  • Hi,

    >>If i put a MessageBox.Show() in the Load event of the base WinForms (in the separate assembly) - i get this messagebox at design time!

    Each elements displayed in Visual Studio  our can see is an instance, otherwise they will not be displayed on the UI interface,  Visual Studio would load the assembly.

    Probably my explanation is not entirely correct, because it is dealing by visual studio, the specific process we do not know.

    I think your question is really not about WinForm, It should be Visual Studio question.

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 4, 2017 10:48 AM
  • Hi Bob,

    you are right, this is more a Visual Studio question. But i disagree Visual Studio creates a "normal" instance of the object.

    Greetings
    Yannik

    Friday, August 4, 2017 10:59 AM
  • Hi,

    Sorry for my late reply, for your question, I suggest you ask question in Visual Studio forum, maybe you can get a professional answer.

    And I would suggest you stop to try it, because I think it is no purpose to do so. You have many ways to avoid it.

    If you need a standard way to declare events in a base class so that they can also be raised from derived classes. You can refer to this link:

    https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/events/how-to-raise-base-class-events-in-derived-classes

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, August 7, 2017 4:37 AM