MySQL: Online
Load: High
Sandbox: Ready

Common CounterStrikeSharp Compile Errors Explained

When a plugin fails to compile, the log is long and full of codes. You rarely need all of it. Look for the first line that starts with error, take its code and match it below. Fixing the first error often removes all the others, because one problem can trigger dozens of messages.

1

CS0246: type or namespace not found

The compiler does not know a class you use. Either a using line is missing at the top of the file, or the package that contains the class is not referenced in the project file. For game types such as CCSPlayerController, check that the CounterStrikeSharp.API package is referenced and that the file has using CounterStrikeSharp.API.Core.

error CS0246: The type or namespace name 'CCSPlayerController' could not be found (are you missing a using directive or an assembly reference?)
2

CS0103: name does not exist in the current context

You used a name the compiler cannot see from that place. It is often a typo, a variable declared in another method, or a class that needs its own using line. For example ChatColors comes from CounterStrikeSharp.API.Modules.Utils.

error CS0103: The name 'ChatColors' does not exist in the current context
3

CS1061: no definition for a member

The class exists, but it has no property or method with that name. Typical causes are a typo, or code written for another CounterStrikeSharp.API version in which that member was added, renamed or removed. If it is someone else's plugin, try the Current option in our version prompt.

error CS1061: 'CCSPlayerController' does not contain a definition for 'SomeMember'
4

NU1101: package not found

NuGet cannot find a package with that exact name. Check the spelling in the project file, because one wrong letter is enough. If the package is private, or only exists in someone else's own feed, it cannot be restored by a public compiler and you need its source code instead.

error NU1101: Unable to find package SomePackage. No packages exist with this id in source(s): nuget.org
5

NETSDK1045: the SDK does not support this .NET version

The project asks for a .NET version newer than the SDK that is compiling it. Install a newer SDK, or lower the TargetFramework. With our compiler, the version prompt lets you choose a target the compiler supports.

error NETSDK1045: The current .NET SDK does not support targeting .NET 10.0.
6

MSB9008: referenced project does not exist

The project file points to another project, usually in a folder next to it, that was not included in the upload. Upload the complete repository folder, not only the single plugin folder, so the shared project is there too.

error MSB9008: The referenced project '../Shared/Shared.csproj' does not exist.
7

CS8618: warning about non-nullable properties

This one is only a warning, so it does not stop the compile. It tells you a property could stay empty. You can ignore it for a quick test, or fix it by giving the property a default value, such as an empty string, or by marking it with a question mark.

warning CS8618: Non-nullable property 'Name' must contain a non-null value when exiting constructor.
8

Compiles but still does not load

A plugin with zero errors can still fail on the server. The usual reasons are a different CounterStrikeSharp.API version on the server, or copying the wrong files. If this is your case, continue with the guide on plugins that are not loading.

Was this tutorial useful?

Page generated in 0.015 seconds
CounterStrikeSharp Web Compiler V1.0 - Made with by RomaniaBarlap for the community.