Windows forms not showing

using Rhino;
using Rhino.PlugIns;
using System.Drawing;
using System.Windows.Forms;

namespace PopUpDefaults
{
    ///<summary>
    /// <para>Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived
    /// class. DO NOT create instances of this class yourself. It is the
    /// responsibility of Rhino to create an instance of this class.</para>
    /// <para>To complete plug-in information, please also see all PlugInDescription
    /// attributes in AssemblyInfo.cs (you might need to click "Project" ->
    /// "Show All Files" to see it in the "Solution Explorer" window).</para>
    ///</summary>
    public class PopUpDefaultsPlugin : Rhino.PlugIns.PlugIn
    {

        public PopUpDefaultsPlugin()
        {
            
            Instance = this;
        }

        ///<summary>Gets the only instance of the PopUpDefaultsPlugin plug-in.</summary>
        public static PopUpDefaultsPlugin Instance { get; private set; }

        // You can override methods here to change the plug-in behavior on
        // loading and shut down, add options pages to the Rhino _Option command
        // and maintain plug-in wide options in a document.
        protected override LoadReturnCode OnLoad(ref string errorMessage)
        {
            RhinoApp.Initialized += OnRhinoInitialized;
            return base.OnLoad(ref errorMessage);
        }
        private void OnRhinoInitialized(object sender, System.EventArgs e)
        {
                RhinoApp.WriteLine($"Plugin Loaded");
                var form = new PluginSettingsForm();
                form.StartPosition = FormStartPosition.CenterScreen;
                form.Size = new Size(800, 500);
                form.BackColor = ColorTranslator.FromHtml("#1c1c1e");
                form.FormBorderStyle = FormBorderStyle.None;
                form.Visible = true;
                form.Show();
        }
    }
}

In the above code like when i use the debugging mode the form shows up correctly at the start when the plugin is loaded but when i build the project and try to load the plugin in Rhino normally the form does not show up on start
Any help?