How to Fix Error CS0246: "Type or namespace not found" in .NET Core by@davidebellone

How to Fix Error CS0246: "Type or namespace not found" in .NET Core

Davide Bellone | Code4IT HackerNoon profile picture

Davide Bellone | Code4IT

I write about .NET development and general coding stuff. - developer - blogger - speaker -

Have you encountered the type or namespace not found CS0246 error in .NET core? Well, so did! Here's how it happened to me and how I fixed it.

Something strange happened today.

I developed a Class Library in .NET Framework and I tested it with the related test library.

So I've integrated the library into another project. Everything was fine, I used that library without problems. But, all of a sudden:

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

What?!? I've been using it for the whole week. I've tested it. I've added the reference, and the Intellisense works as well.

C'mon, the class is here!

Clean the solution... nothing happens.

Close Visual Studio... still nothing.

Have a coffee... well, better now.

Suddenly, a doubt: what if I've created it in .NET Core instead of .NET Framework?

And, obviously... no, it wasn't that.

The Real Way to Fix the Namespace Not Found Error in .NET Core

But I was close: the Class Library was in .NET Framework 4.7.2 but the application was in .NET Framework 4.7.1It was the patch version!

So, I just downgraded the class library version through Visual Studio, and everything went well again.

How to Downgrade

You can find the version in the Properties screen of the project (right-click on the project in the Solution Explorer or Alt+Enter) in the Application tab, then under the Target framework field.


So, the lesson is: know your enemy, and check for slight details.

Previously published at


Signup or Login to Join the Discussion


Related Stories