Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS.NET 2015 project won't build

Last week I created a ASP.NET 5 MVC project using VS.NET 2015 Preview. I then used NuGet to get the MongoDB driver (mongocsharpdriver) and I wrote some code and with that added some documents to the database. I started a new project today along those same lines but it wouldn't build. It says the type or namespace MongoDB can't be found even though I have intellisense for it. So I opened the original project and now that one won't build, same exact error. My project properties is set to target CLR, not Core -- that MongoDB library doesn't work with Core. Has anyone run into this problem and know how to fix it? I'm pretty sure I'm not going crazy.

All I do to reproduce the problem is start a new ASP.NET Web Application, then pick ASP.NET 5 Starter Web, then install MongoDB from NuGet, then add an import to it in the HomeController.cs. Then it complains about it not being found in Core, even though I'm not targeting Core.

This is the error when compiling following my steps above:

Error   CS0246  The type or namespace name 'MongoDB' could not be found (are you missing a using directive or an assembly reference?)   Bug.ASP.NET Core 5.0    HomeController.cs
like image 982
GregInWI2 Avatar asked Jan 08 '15 16:01

GregInWI2


People also ask

Why is Visual Studio not building?

Check your settings in Tools->Options. Go to the projects and Solutions area, Build and Run page. There is a setting "On Run, when projects are out of date:" Make sure this is set to 'Always build.

How do I create a VB project in Visual Studio 2015?

Open Visual Studio. On the start window, choose Create a new project. In the Create a new project window, choose Visual Basic from the Language list. Next, choose Windows from the Platform list and Console from the Project types list.


1 Answers

As per my best knowledge ASP.net core 5.0 framework does not support many of existing Nuget library and assembly.

Go to project.json and remove ASP.net Core 5 from framework section.

like image 60
dotnetstep Avatar answered Sep 27 '22 19:09

dotnetstep