[Need Help] Trying to create a Auto Start Class with Plugins



  • Ive been trying to create a class that holds methods that auto-start when OB is launched.
    I'm doing this in hope of Implementing a Settings system for my plugin. As well as implementing a Change-Log.

    I've been viewing other plugins as an example but after being stumped for a few hours i figured its time to ask for help because I'm losing my mind Staring at this.

    My Code is Below

    using System;
    using System.ComponentModel;
    using System.IO;
    using RuriLib;
    using PluginFramework;
    using RuriLib.Interfaces;
    
    namespace Anomaly
    {
    public class AutoStart : IPlugin
        {
            public string Name
            {
                get
                {
                    return "AutoStart";
                }
            }
    
    
            private BackgroundWorker BWWorker = new BackgroundWorker();
    
            private IApplication app;
    
            private void Work(object sender, DoWorkEventArgs e)
            {
                try
                {              
                    StreamWriter sw = new StreamWriter("Test.txt");
                    sw.WriteLine("Test");
                    sw.Close();
                }
                catch (Exception ex) { app.Logger.Log($"Something Fucked Up: {ex}", LogLevel.Error, false); }
            }
    
            public OnStart(IApplication app)
            {
                this.app = app;
                this.BWWorker.DoWork += this.Work;
                this.BWWorker.RunWorkerAsync();
                app.Logger.Log("Anomaly Plugin Initialized.", LogLevel.Info,false);
            }
        }
    }
    
    

    I have this saved into its own class named AutoStart.cs

    The Error i cannot solve to see if this method even works is
    alt text

    I know enough C# to know Return Types, However I don't know enough about OB to figure out what the hell its asking me for. Ive sat here trying different things for hours now and i cant figure out what it wants. Any help is appreciated, Thank you.


  • Admin

    Hey! If you want to make a constructor in C# you need to call it with the same exact name as the class, so in this case change OnStart to AutoStart to match the class name and the error will go away ^_^



  • @Ruri oh ffs, thanks. im gonna go cry now ❤


Log in to reply