MacKenzie Mickelsen
MacKenzie Mickelsen

Reputation: 155

.Net Standard 2.0 Class Library produces error CS0246

So I am working on a Asp.Net Core 2.0 web application. I am doing some refactoring and wanted to move some classes into a referenced class library. I did some reading and found that .Net Standard is the new way to go about that.

So I created a new .Net Standard 2.0 Class library then created my class. I was able to compile the code just fine. I referenced the library in my Asp.Net Core 2.0 web app and everything was fine until I tried to use the class. It's just a simple model class no logic just properties.

When I try to use it I get error CS0246: The type or namespace name 'LoginRequest' could not be found (are you missing a using directive or an assembly reference?). I have no idea what I am doing wrong. Any help at all would be greatly appreciated.

Thanks in advance

Upvotes: 0

Views: 750

Answers (1)

Prateek Pandey
Prateek Pandey

Reputation: 863

I have gone through the same flaw. If you are adding a new file in .NET Standard library then you need to restart the Visual Studio to make that file's code come into effect. However, your intelisense will work without any VS restart.

Alternatively, you can add your class to an already existing file.

Upvotes: 2

Related Questions