question

JackWong avatar image
0 Votes"
JackWong asked JialeXueMSFT-4441 answered

How to debug winform userControl in designer with dotnet 6?

I want to know how to debug winform userControl in design time?

  1. dotnet sdk version:6.0.403;

  2. IDE:Visual Studio 2022 community 17.3.0;

  3. as the document say,as fallow:
    259376-image.png

windows-forms
image.png (5.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JackWong avatar image
0 Votes"
JackWong answered JackWong commented
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @96623152, Thank you for your sharing. Does it be resolved?

0 Votes 0 ·
JackWong avatar image JackWong JialeXueMSFT-4441 ·

No, There is no good Way. Can you give some suggestion.

0 Votes 0 ·
JialeXueMSFT-4441 avatar image
0 Votes"
JialeXueMSFT-4441 answered

Hi @JackWong, Welcome to Q&A.

From my testing, this document works fine for .Net 6.

Both my library files and project are .Net 6

My steps:

  • Create a .Net 6 usercontrol library file and modify the design of UserControl1.

  • Add the following code to the class:

    private string demoStringValue = null;
    [Browsable(true)]
    public string DemoString
    {
        get
        {
            return this.demoStringValue;
        }
        set
        {
            demoStringValue = value;
        }
    }


  • Build library files.

  • Add a breakpoint to the property.

  • Modify the startup item of the project to the current project.

263708-image.png

  • Create a new .Net 6 winform project, add the library file to reference.

  • Drag usercontrol1 into design and add a button.

  • Add the following code to the button:

    private void button1_Click(object sender, EventArgs e)
    {
        userControl12.DemoString = (string)button1.Text;
        MessageBox.Show(userControl12.DemoString);
    }


  • You can see it hit the breakpoint.

demo2

Best Regards,
Jiale


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



image.png (21.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.