Why am I getting error CS0246: The type or namespace name could not be found?

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).


  1. On the Solution Explorer tab right click and select Properties

  2. Resolve this issue by updating the Target Framework in the project application settings.

For instance, In my case the project was compiling with .net framework version 4.5.1 but the dll which were referenced were compiled with the version 4.6.1. So have updated the my project version. I hope it works for you.

enter image description here


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...)


Edit: Oh ignore me, you're not using Visual Studio.

Have you added the reference to your project?

As in this sort of thing:

enter image description here


It might be due to "client profile" of the .NET Framework. Try to use the "full version" of .NET.