Why am I getting error CS0246: The type or namespace name could not be found?
I am using Snarl C# API to send notifications to snarl.

Now I have saved the content of above url in a file named SnarlNetwork.cs and the content of my test.cs file are:

using SnarlNetworkProtocol;
https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196
Stack Overflow
I was using .NET Framework 4.5 but my new library had .NET Framework 4.5.2 and I got the same issue when I tried to build. I solved it by updating my project from 4.5 to 4.5.2 (same as my library).

This is the problem:

C:\Users\Noob\csharp>csc test.cs

You haven't added a reference to the DLL. You need something like:

C:\Users\Noob\csharp>csc test.cs /r:SnarlNetwork.dll

(or whatever the assembly is called).

Alternatively, if you haven't got it as a separate library, just compile both files:

C:\Users\Noob\csharp>csc test.cs SnarlNetwork.cs

If you haven't compiled an assembly but want to, you can use:

csc /target:library /out:SnarlNetwork.dll SnarlNetwork.cs csc Test.cs /r:SnarlNetwork.dll

(In fact, specifying the output file is unnecessary in this particular case, but it's still clearer...)

This usually happens to me when I have a using statement but have forgotten to reference the assembly that defines the namespace.

But in your case, as the namespace is defined in a file in your project, you have forgotten to tell the compiler about the snarlnetwork.cs file.

See csc compiler examples

I also got this error due to a missing reference. The reason I did not notice is because Resharper offers to add a using and a reference. Adding the using succeeds (but it's highlighted grey), syntax highlighting of missing classes works (sometimes), but adding the reference fails silently.

When manually adding the reference an error pops up, explaining why adding the reference fails (circular reference). Resharper did not pass this error on to the GUI.

I had this issue when I first cloned my project from Git to Visual Studio. I just had to update my NuGet packages, and then I was good to go!

Project > Manage NuGet Packages... > Then update the packages. It notified me and there was a yellow bar with a button that I pushed and it downloaded the packages!