error

Preprocessor directives must appear as the first non-whitespace character on a line

Nabeel
May 20, 2022
0 Comments
Home
error
Preprocessor directives must appear as the first non-whitespace character on a line

 Preprocessor directives must appear as the first non-whitespace character on a line



Here are some solutions collected.

1.
event, you must have a method with the same name declared in the code behind page like below,

protected void #btnLogin_Click(object sender, EventArgs e)
{
}

But in C# cs files, as the error explains preprocessor directives (#) must appear as the first non-whitespace character that's why the error happens.

Solution would be to adhere to proper naming conventions. See here.



2.

Preprocessor directives start with #. You have a trailing # in line 10.
It looks like you use Visual Studio which should mark the line in red. Also the error should tell you which line looks wrong.
Edit: You probably just opened the file in Visual Studio, which will not load any assemblies. Please open your C# project from Unity, right-click in the project explorer and choose "open C# project" or similar

Honestly this post should be removed for low effort, a simple Google search with your error would've yielded tons of results


3.

I fixed it by removing this line









Blog authors

No comments