ASP.NET V5-RC1: Cannot reference class library from web application project - asp.net

I have an issue with ASP.NET V5 RC1 where it won't let me add a reference to a class library (targeting the 4.6 framework) from my web application. When I right click references and select "Add reference" and then select Solution-> Class library, it shows an error that says
---------------------------
Microsoft Visual Studio
---------------------------
The following projects are not supported as references :
- The project XYZ has a target framework that is incompatible or has version higher than the current project and cannot be referenced.
Hopefully I'm just doing something silly, but google isn't helping. I've tried changing the target framework for the class library to no avail. Can anybody tell me what I've done wrong?

Related

Why Nuget package need to be added in the dependent project for execution?

Created 3 projects in a solution.
A. Class library targeting .NET Standard Library
Retrieving a database value using System.Data.SqlClient which is added via NuGet
B. .NET Core console application : Referencing project A to display the DB value
C. .NET Framework console application : Referencing project A to display the DB value
Project B works fine when running, but Project C gives below runtime error.
If I add the System.Data.SqlClient in Project:C, then it will start working. Is it mandatory to add dependent NuGet packages of project A to project C?
Also I want to know the reason of different behavior between .NET Core and .NET Framework console applications.

Having trouble referencing .NET Standard class library using SQLProvider from .NET Core project

Reproduction of problem here: https://github.com/Arrow7000/SqlProviderTest
I'm fairly new to the .NET world so am having trouble wrapping my head around exactly what the problem is.
I've tried to use the SQL type provider directly in an F# .NET Core project, but had a bunch of problems getting it to work. From what I can tell that's due to incompatibilities between .net core and type providers.
So what I am trying instead is to have the SQL type provider code encapsulated in a .NET Standard project that I can reference from my main Core project.
I've managed to reproduce the problem in a minimal GitHub repo located here which demonstrates both that
the type provider is working in Visual Studio 2019 with IntelliSense, but
despite this I still get a build error when I try to start the Main project
The build error is
Unable to find the file 'C:\projects\SqlProviderTest\SQLStuff\bin\Debug\netstandard2.0\SQLStuff.dll' in any of
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.2.0\ref\netcoreapp2.2
C:\projects\SqlProviderTest\Main
C:\Users\Aron\.nuget\packages\fsharp.core\4.6.2\lib\netstandard1.6
Why isn't the project reference simply working as expected? I've tried adding <Private>True</Private> to the project reference but that didn't make any difference
P.S. in case it matters, I'm developing on Windows but the app gets deployed on a Docker container.

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

Missing Linq to SQL namespace in Visual Studio 2012 Web Site Project

The hosting provider for one of the web sites I manage has forced us to only be able to modify the site as a web project instead of as a web application. When it was initially a web application it was working fine, but after converting to a web site project I had many issues involving missing namespaces and references and was able to resolve them by placing all of my libraries inside of the top-level App_Code folder of the web site. I have one last issue with my linq-to-sql class - in Visual Studio the class is recognized now that it's in the top level App_Code folder, but when I call a page which references it I get the following error:
The type or namespace name 'LIFH_IntakesDataContext' could not be found (are you missing a using directive or an assembly reference?)
Initially there was no namespace whatsoever, but in my attempts to fix this I addded a "LIHS" namespace and placed the Data Context within that:
Here are the references for the site:
And here is the Build configuration:
And, here is my directory structure (Linq-to-SQL class is referenced in the circled "reports.aspx" page):
Code in reports.aspx:
Both the master page and the reports page are both in the LIHS namespace.
I am developing on Visual Studio 2012 and the application pool is set to .NET 2.0. The hosting provider does not allow anything above 2.0.
I have researched and found many references to my issue but most of them solve the problem by converting to a web application, which I cannot do, or by changing the target framework or by using a namespace, which I have done, but to no avail. I would appreciate any insight on this.
Pay Attention: Linq is only available in .Net 3.5 and later
If you are using .net 2.0 it wont work.
You can see it in your screenshot.
Hope it helps.
Mike

Adding project reference in visual studio

I added a project reference of my Business Logic project to my console application. I can reference the project and its classes in the code of my console application. Weirdly, when I build the project, the build fails and the classes which referenced says Type is not defined.Has anybody come across an issue like this?
You have to import name space in your console application class where you are trying to use the business logic application class.
I have selected the incorrect target framework .net framework client profile 4.0 where it should be .net framework 4. Issue rectified and now I can build the project.

Resources