C#, Enumeration nullReferenceException was not handled.

Asked 2 years ago, Updated 2 years ago, 47 views

NullReferenceException was not handled.
Object reference is not configured for the object instance.
says the error.

mi1.cs

namespace mip
{
    public enum enumMessageType
    {
        mtA, mtB, mtC, ...
    }
afterthought

Form1.cs

namespace mipTest
{
    public partial class Form 1:Form
    {
        private void btnInsert_Click(object sender, EventArgse)
        {
            QueueInfo qi = new QueueInfo();
            qi.CommandInfo.MessageType=enumMessageType.mtA;←This is where the error occurs.
            afterthought

Do you have any clue to the solution?
Thank you for your cooperation.

c#

2022-09-30 20:51

1 Answers

Run debugs, break the line where the error occurs, and look for null.

As it looks, the CommandInfo member variable in the QueueInfo class is likely not initialized.


2022-09-30 20:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.