Can I use a .NETFramework project within a .NETCoreApp project? - asp.net

I am building out a website using WebAPI in .NETCoreApp v1.0. However, I am trying to connect to an API for blackbook which is in another project that is built in .NETFramework v4.5.
When I attempt to add a reference to it in Reference Manager I get the following error:
The following projects are not supported as references:
BlackbookWCFProxy has target frameworks that are incompatible with targets in current project MainProject.
MainProject:
.NETCoreApp,Version=v1.0
BlackbookWCFProxy:
.NETFramework,Version=v4.5
So does that mean I have to scrap my entire project because a single API was built in .NETFramework? What about the other APIs I want to use? How can I get it to work nicely with my project?

You should install .NET Core RTM to make a .net core project so you will find this on following link

Related

How Syncfusion.blazor could work using refrences?

image view
i have installed syncfusion.blazor component from nuget package and its updated in references, but when I am trying to use it its showing refrence couldnot be found, what could be the possible reason and solution ?
From what I've tested, it looks like you created a blazor webassembly app based on .Net Core 3.1(out of support).
But if you check the syncfusion.blazer 20.4.0.50 nuget package, you can find that it is based on .Net 6.0 or .Net 7.0.
At least try to use .Net 6.0, .Net Core 3.1 is out of support.
Based on the given screenshot, you have registered the Syncfusion Blazor service in the server project (DMSBlazor.Server). To resolve this issue, you should register it in the client project's ~/Program.cs file. For more details, refer to this link.

.net standard library with HttpCient for xamarin forms

I was trying to create a common library for using HttpClient to consume an API. I was planning to make it in .net standard so as to share it with my xamarin.forms project right now and any future ones. However the highest version of .net standard I managed to use was 1.0. HttpClient needs standard2.0. I have included the latest version of .netstandard nuget into my xamarin.forms.
I have noticed that xamarin.forms runs in net4.5. According to the documentations the max I can go with this is standard1.1. Is there any work around around these to a .net standard common project or is my only option to make a .net framework project/xamarin portable library?
I used to be in the same situation and I managed to pull through this. First I tried to upgrade my current PCL project to .netStandard, but it was always failing, so I decided to create a new Project A Class Library (.NETStandard), moved all my files to the new project and re-install all nuget packages.
New project configuration:
Target Framwork: .NET Standard 2.0
Output type: Class Library
Make sure you're using Microsoft Visual Studio > version 15.3
Hope it helps.
I did manage to get HttpClient working in .net standard after manually importing the class. It needed an additional reference which is why it threw an error when I downgraded from .netcore.
This seems to work sometimes and throws reference errors other times. These errors go when I close and re-open visual studios.

Trying to build an ASP.NET Core API within a .NETFramework application

I am trying to build a .net core API using MVC, but I am trying to add it to an application that was not build on ASP.NET Core. When I try and configure the interfaces to be used in the core app (Setup.cs) I am not able to reference the interface. When trying reference the solution within the core app, I get the error
"The following projects are not supported as references: [solution name] has target frameworks that are incompatible with the targets in current project.
.NETCoreApp,Version=1.0
.NETFramework,Version=v4.5
What is the best way to be able to reference a .NETFramework project within a .NETCore project?
from comment above I realized it was not possible. I was not able to use the .net standard version in my core app.

How to create a .NET Core library I can reference from a .NET Core App (Web API)

I'm working in Visual Studio 2015 Update 3 and .NET Core 1.0. I have a Web API project which is of type .NETCoreApp v1.0. When I add a .NET Core class library, it is of type .NETStandard v1.6. I can add this library to the Web API project as a reference, but it is not recognised when I try to add using statements.
If I create another project of type .NETCoreApp, I can reference it and use the classes without a problem.
How do I make use of a .NET Core class library from my .NET Core App?
Edit/Update:
This appears only to be an editor/Intellisense issue, because despite the editor warnings, the .NETCoreApp does build and run, calling into the class library.
I am running Resharper, which I see is blamed for similar problems with other types of projects: I have checked that I have the latest version and have cleared the Resharper cache and restarted VS2105.
This is a Resharper issue. At this time Resharper (v2016.1.2) does not support .NET Core 1.0.
There are 2 possible solutions:
Uninstall Resharper, and the Visual Studio native intellisense works.
Install the Resharper 2016.2 EAP (Early Access Program) version. I've done this and it's working. Obviously it comes with the caveats of any EAP/beta product.
Here is a link to the Jetbrains forum post where I was told .NET Core 1 was not yet supported and pointed to the EAP version.
Once you've built a library that targets netstandard1.X, you can either:
Produce a NuGet package with dotnet pack and host it locally or on NuGet. Then, install it in your netcoreapp project as any other dependency.
If your library and application are part of the same solution, make a local reference:
project.json
"dependencies":{
"MyLibrary.Core": {
"version": "1.0.0",
"target": "project"
}
}
target: project tells dotnet to look in the current solution for the dependency, instead of using your NuGet feeds. Again, this only works if you are developing the library and application in the same solution.

Attempt by method 'HttpConfiguration..ctor(HttpRouteCollection)' to access method 'HttpConfiguration.DefaultFormatters()' failed

I have a Web API that has version 5.1.2 of the Microsoft.AspNet.WebApi.Client package installed.
I am trying to access the API from an ASP.NET MVC application, which also has the same version of the package installed.
However, in the Global.asax of the Web API project, on the line below, I get the following exception:
WebApiConfig.Register(GlobalConfiguration.Configuration);
Attempt by method 'System.Web.Http.HttpConfiguration..ctor(System.Web.Http.HttpRouteCollection)' to access method 'System.Web.Http.HttpConfiguration.DefaultFormatters()' failed.
I found that this error occurs when you have multiple projects pointing to different .net versions.
For example if you have a Web API project targeting .net 4.5 and a unit test project targeting .net 4.5.3 it seems that default settings mean nuget may silently update the .net 4.5 project references to incompatible versions one day when you open visual studio and cause your Web API project to fail with the recondite 'Attempt by method 'HttpConfiguration..ctor(HttpRouteCollection)' to access method 'HttpConfiguration.DefaultFormatters()' failed' error.
To avoid the error drop the higher .net version back on the new project to match the Web API project - for this example right click the unit test project, click properties, then change the target framework to .net framework 4.5.
In my case it was a discrepancy between versions of Microsoft.AspNet.WebApi.Client and Microsoft.AspNet.WebApi.Core, I tried updating both to the same version and it worked.
In my case, the issue was solved when I installed the Microsoft.AspNet.WebApi.Core as well. So three libraries should present and be in harmony (uninstall / install) Microsoft.AspNet.WebApi.Client, Microsoft.AspNet.WebApi.Core and Newtonsoft.json
same for the above answers in my case also it is working good after updating or reinstalling packages
Microsoft.AspNet.WebApi.Client
Microsoft.AspNet.WebApi.Core

Resources