Skip to content
RustPluginGenerator
CS0246Oxide + Carbon

Fix CS0246: type or namespace name could not be found (Oxide)

CS0246 means the C# compiler cannot resolve a type name you used, usually because the namespace that declares it was never imported. Add the missing using directive (for CUI types that is Oxide.Game.Rust.Cui) and the plugin compiles on the next save.

Server console
Error while compiling WelcomePanel:
[1] The type or namespace name 'WelcomePanelContainer' could not be found (are you missing a using directive or an assembly reference?) at 25:13

Why it happens

C# resolves type names only from imported namespaces plus the files in your project. Oxide plugin files are compiled individually, so every helper type has to come from an explicit using. CuiElementContainer, CuiPanel, CuiLabel, CuiButton and CuiHelper live in Oxide.Game.Rust.Cui; without that line the compiler stops at the first of these it meets. The same applies to collection types: List<>, Dictionary<>, HashSet<> need System.Collections.Generic, and JsonProperty needs Newtonsoft.Json. A second common trigger is a real typo in the type name, or using a type from another plugin or assembly that Oxide has not loaded. NetworkableId is a related case where the type exists in the game assembly but you referenced it without qualification. The reported line and column point at the first usage, which is almost always the correct place to look.

How to fix it

  1. Read the reported line. If it mentions a CUI type, add using Oxide.Game.Rust.Cui; at the top of the file, before the namespace.
  2. If it mentions List or Dictionary, add using System.Collections.Generic;. If it mentions JsonProperty, add using Newtonsoft.Json;.
  3. Check spelling — CuiElementContainer has two capital letters in a row (Cui + Element). CuielementContainer fails the same way.
  4. Save the file. Oxide reloads automatically; you can also run oxide.reload WelcomePanel in the server console.
  5. Confirm the fix by looking for Loaded plugin WelcomePanel v1.0.0 by RustPluginGenerator. If another numbered error appears, the plugin is still unloaded and you need to fix that line as well.

Before and after

BeforeFails
using System.Collections.Generic;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Welcome Panel", "RustPluginGenerator", "1.0.0")]
    [Description("Shows a welcome panel to every player who joins the server")]
    public class WelcomePanel : RustPlugin
    {
        private const string PanelName = "WelcomePanel.Main";
        private readonly Dictionary<string, string> messages = new Dictionary<string, string>
        {
            ["Title"] = "Welcome to the server",
            ["Hint"] = "Type /help for commands"
        };

        private void OnPlayerConnected(BasePlayer player)
        {
            if (player == null)
            {
                return;
            }

            // Typo: forgot to reference the correct panel container type
            WelcomePanelContainer container = new WelcomePanelContainer();

            // Build the panel and labels using a helper object the plugin author forgot to define/import
            var ui = new UiBuilder(container);
            string panel = ui.AddPanel("0.1 0.1 0.1 0.9", "0.35 0.4", "0.65 0.6", PanelName);

            ui.AddLabel(messages["Title"], 20, "0 0.5", "1 1", panel);
            ui.AddLabel(messages["Hint"], 14, "0 0", "1 0.5", panel);

            ui.Show(player);
        }
    }
}
AfterFixed
using System.Collections.Generic;
using Oxide.Game.Rust.Cui;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Welcome Panel", "RustPluginGenerator", "1.0.0")]
    [Description("Shows a welcome panel to every player who joins the server")]
    public class WelcomePanel : RustPlugin
    {
        private const string PanelName = "WelcomePanel.Main";
        private readonly Dictionary<string, string> messages = new Dictionary<string, string>
        {
            ["Title"] = "Welcome to the server",
            ["Hint"] = "Type /help for commands"
        };

        private void OnPlayerConnected(BasePlayer player)
        {
            if (player == null)
            {
                return;
            }

            var container = new CuiElementContainer();
            string panel = container.Add(new CuiPanel
            {
                Image = { Color = "0.1 0.1 0.1 0.9" },
                RectTransform = { AnchorMin = "0.35 0.4", AnchorMax = "0.65 0.6" }
            }, "Overlay", PanelName);

            container.Add(new CuiLabel
            {
                Text =
                {
                    Text = messages["Title"],
                    FontSize = 20,
                    Align = TextAnchor.MiddleCenter
                },
                RectTransform = { AnchorMin = "0 0.5", AnchorMax = "1 1" }
            }, panel);

            container.Add(new CuiLabel
            {
                Text =
                {
                    Text = messages["Hint"],
                    FontSize = 14,
                    Align = TextAnchor.MiddleCenter
                },
                RectTransform = { AnchorMin = "0 0", AnchorMax = "1 0.5" }
            }, panel);

            CuiHelper.AddUi(player, container);
            timer.Once(10f, () => CuiHelper.DestroyUi(player, PanelName));
        }
    }
}

FAQ

Does Oxide print something when the plugin compiles?

No. Oxide only prints a Loaded plugin <Title> v<Version> line, and only when loading succeeds. If the compile fails you get the Error while compiling block and the plugin stays unloaded.

Why does my IDE not show the error but Oxide does?

Your editor may resolve types from a different project or SDK. Oxide compiles your single .cs file against its own reference set. If using Oxide.Game.Rust.Cui; is present and the editor still complains, make sure you did not add it inside the namespace block but outside the class.

Is the CS code in the console line?

Only Carbon prints the code. Oxide shows a numbered message with line and column ([1] ... at 12:13). The exact compiler output is in oxide/logs if you need the full text.

What if I use the CUI type inside a chat command only?

A using directive is file-wide, so one line at the top is enough. Do not add it inside the method or inside namespace Oxide.Plugins next to the class — it must be at the top level, before the namespace.

Different error?

Paste the full console output and get the cause and a fix in plain English.

Open the error explainer

Skip the debugging

Generated plugins are compiled before you get them, and compiler errors are fixed automatically.

Generate a plugin

2 free plugins a month, no card.

Last updated Oct 26, 2026.

Get plugins that compile first time

Generate