title: GetConstructor() method returning null value in .Net 6 but the same returning values in .Net core 3.1
body: <p>I am trying to save the mailmessage in file. So i have used below code to save the mailmessage in file. the same code working in .Net core 3.1 but it's throwing error on .Net 6.</p>
  <p><strong>Error Info:</strong>
  Object reference not set to an instance of an object.</p>
  <p>Its happening because for GetConstructor() method returning null value</p>
  <p><strong>Please find the snippet of code:</strong></p>
  <pre><code>Assembly assembly = typeof(SmtpClient).Assembly;
              Type _mailWriterType =
                assembly.GetType(&quot;System.Net.Mail.MailWriter&quot;);
  
              using (FileStream _fileStream =
                     new FileStream(FileName, FileMode.Create))
              {
                  // Get reflection info for MailWriter contructor
                  ConstructorInfo _mailWriterContructor =
                      _mailWriterType.GetConstructor(
                          BindingFlags.Instance | BindingFlags.NonPublic,
                          null,
                          CallingConventions.HasThis,
                          new Type[] { typeof(Stream) },
                          null);
  
                  // Construct MailWriter object with our FileStream
                  object _mailWriter =
                    _mailWriterContructor.Invoke(new object[] { _fileStream });
  
                  // Get reflection info for Send() method on MailMessage
                  MethodInfo _sendMethod =
                      typeof(MailMessage).GetMethod(
                          &quot;Send&quot;,
                          BindingFlags.Instance | BindingFlags.NonPublic);
  
                  // Call method passing in MailWriter
                  _sendMethod.Invoke(
                      Message,
                      BindingFlags.Instance | BindingFlags.NonPublic,
                      null,
                      new object[] { _mailWriter, true, true },
                      null);
  
                  // Finally get reflection info for Close() method on our MailWriter
                  MethodInfo _closeMethod =
                      _mailWriter.GetType().GetMethod(
                          &quot;Close&quot;,
                          BindingFlags.Instance | BindingFlags.NonPublic);
  
                  // Call close method
                  _closeMethod.Invoke(
                      _mailWriter,
                      BindingFlags.Instance | BindingFlags.NonPublic,
                      null,
                      new object[] { },
                      null);
              }
  </code></pre>