Udostępnij za pośrednictwem


ASP.NET CORE 1.0: Multiple Frameworks Target Issues

The Core ASP.NET had several changes after being updated from RC1 to RC2 version. Now, after creating a new ASP.NET Core Web Application (.NET Core) , only the .NET CORE (netcoreapp1.0) is added by default. core

 

To add full .NET Framework into the project, you must include a reference to it, through the project.json configuration file, as:

“frameworks”: {
“netcoreapp1.0″: {
“imports”: [
“dotnet5.6″,
“dnxcore50″,
“portable-net45+win8″
],
“dependencies”: {
“Microsoft.NETCore.App”: {
“version”: “1.0.0-rc2-3002702″,
“type”: “platform”
}
}
} ,
    “net461″: { }
},

However, after saving the changes, the following error will be generated:

error NU1002: The dependency System.Runtime.Loader 4.0.0-rc2-24027 does not support framework .NETFramework,Version=v4.6.1.

 

erro

 

This error occurs because the dependence Microsoft.NETCore.App is not compatible with FULL version of the .NET Framework. To eliminate the error, you must open the project.json file and move the Microsoft.NETCore.App dependency out of “dependencies”: dep

 

Into a new “dependencies” section under the “netcoreapp1.0” key in “frameworks”, as:

“frameworks”: {
“netcoreapp1.0″: {
“imports”: [
“dotnet5.6″,
“dnxcore50″,
“portable-net45+win8 “],
      “dependencies”: {
        “Microsoft.NETCore.App”: {
          “version”: “1.0.0-rc2-3002702″,
          “type”: “platform”
        }
}
},
“net461″: { }
},

 

I hope have helped.

Comments

  • Anonymous
    July 01, 2016
    Thank your for the tip
  • Anonymous
    August 09, 2016
    I get this error "error NU1002: The dependency System.Runtime.Loader 4.0.0-rc2-24027 does not support framework .NETFramework,Version=v4.6." as you describe but still it is not working. I only build for net46 (I exclude netcoreapp1.0) so inspired by this article I remove this dependency entirely: "Microsoft.NETCore.App": { "version": "1.0.0-rc2-3002702", "type": "platform" },However, this gives me lots of other errors such as "error CS0246: The type or namespace name 'IActionResult' could not be found (are you missing a using directive or an assembly reference?)"What am I missing?
    • Anonymous
      August 14, 2016
      Hi Nikola,It is hard to know without the full code. But, take a look at the global.json (file inside the "solutions items" folder of VS). Double-check if the file is point to the last version of .NET Core. "sdk": { "version": "1.0.0-preview2-003121" }If the information is not confidential, you can send me the project.json.
  • Anonymous
    January 08, 2017
    The comment has been removed
  • Anonymous
    January 08, 2017
    The comment has been removed
    • Anonymous
      January 09, 2017
      The comment has been removed
      • Anonymous
        January 10, 2017
        Hi Luis,Thanks for the reply!I commented out the below netcoreapp1.0 from the framework section in my package.json, and it works. “netcoreapp1.0”: {“imports”: [“dotnet5.6”,“dnxcore50”,“portable-net45+win8”],“dependencies”: {“Microsoft.NETCore.App”: {“version”: “1.0.0”,“type”: “platform”}}}But when i clicked on the References section in Visual Studio now, only the ".NET Framework 4.6.1" is listed. The ".NETCoreApp,Version=1.0" was removed. Both of them were there before.Can you please let me know if removing .Net Core entry from the frameworks section means that my project is no longer a .NET core Web Application project but, is, instead, just a .NET Web Application project? Thanks!
        • Anonymous
          January 10, 2017
          Hi Luis,I have a more general question. In your comments, you stated, "Observe that the .NET Framework Full has about 200MB while the .NET CORE has about 20MB. That is why most of the libraries are not compatible with .NET CORE yet." Do you know if Microsoft will or has any plan to make most/all of the .NET Framework Full compatible with .NET CORE? If not, then does it mean we cannot have a .NET Core cross platform project that can reference non-core libraries/projects that use libraries that are not compatible with .NET CORE and fall outside of the 20MB .NET Core framework? Does it also mean we have to find equivalent libraries for the .NET Framework Full in the .NET CORE framework? But since the later is smaller (only 20MB), it does not look like this is doable, which leads it right back to your original comment,"Observe that the .NET Framework Full has about 200MB while the .NET CORE has about 20MB. That is why most of the libraries are not compatible with .NET CORE yet." I'm just wondering because there's a "yet" at the end of your statement...:)Thanks for your time!
          • Anonymous
            January 10, 2017
            Hello Luis,Back to my general question, I have a Xamarin project (using visual studio 2015), from which i can reference my same .NET library(none core) without any issue and without having to make any additional configuration changes to the project settings. I really hope we can do the same from a .NET Core projects.Thanks!
  • Anonymous
    January 10, 2017
    Great question Squid.QUICK ANSWER: No, your project still be a ASP.NET CORE but, the application will use the .NET FRAMEWORK FULL that runs only on Windows.Nowadays, there are two models of Web development: ASP.NET Web Applications and ASP.NET CORE (.NET Framework Full or .NET CORE).The first model (ASP.NET Web App), is the traditional model that is based on System.Web.dll to implement the main functionalities (MVC, WebForms, WebAPI, WCF). In this model, we have for example, the global.asax, web.config, bundling, and so on.Talking about the second model (ASP.NET CORE), everything have changed. The model does not implement all the pipeline inside System.Web.dll for example. When you create a empty project, the request pipeline only knows how to return a text. It depends on you to specify the middleware (MVC, StaticFiles, logs, etc). And all that packages are added in this model as Nuget Packages. We have now a wwwroot folder inside the project. You don't need to have the IIS if you don't want (but if you are using Windows it is strongly recommended to keep).Using this second model, you can opt to use the .NET FULL FRAMEWORK or .NET CORE. You were using both versions to develop, but in time of deployment, you will need to choose the framework that you will use. Note that the .NET CORE is cross-platform, and for example, we don't have Event Viewer class to log the events. We don't have performance counters.For more details, the oficial documentation is: https://docs.microsoft.com/en-us/aspnet/core/ Regards,
    • Anonymous
      January 10, 2017
      Hi Luis,I understand why we need cross-platform features for windows phone, iphone, and android, but i still dont see the need for it for Web Applications other than which host system we are to deploy our web applications on. Please let me know if I'm missing anything.. I'm newbie to both ASP.NET and ASP.NET Core. By the way, Many many Thanks again for your feedback. Time is valuable, so i really appreciate your taking time reading my questions and answering my them! I have been stuck for a long time until i found you!!! Finally you helped me resolve my "core referencing non-core" issue! I read github and stackoverflow but still could not solve the problem... I'm wondering if you can also help me get to the right resource to learn the right way for consuming web services from .NET CORE projects.Prior to the addition of .NET CORE, from a classical .NET class library(non-core), i can use "add service reference" to consume a web service from a provided wsdl file.Now from a .NET Core class library, this option is not even available. I had to download Visual Studio WCF Connected Service from https://marketplace.visualstudio.com/items?itemName=erikcai-MSFT.VisualStudioWCFConnectedService in order to do the same thing. However, this approach did not work completely. It lets me add the web service reference, but i could not see any methods. For example i can only see the request and response object. I could not reference the method to send requests and receive responses.Further, "Visual Studio WCF Connected Service " is not even available for Visual Studio 2017.Can you please advise on the proper ways to consume a web service (rest, soap) from a .net core project?Thanks so much for all of your time!
  • Anonymous
    February 02, 2017
    Very helpful. Thanks!
    • Anonymous
      February 02, 2017
      Thank you Marc.I'm glad to had helped.Regards
      • Anonymous
        February 03, 2017
        The comment has been removed
        • Anonymous
          February 03, 2017
          You have two ways to fix that.The first one, is change the target framework at the dropdown that is available in the left up side of the controller class.The other one, is to remove the netcoreapp1.1 framework and working only with the full framework. In this case you should remove the following code:“netcoreapp1.1”: {“imports”: [“dotnet5.6”,“portable-net45+win8”],“dependencies”: {“Microsoft.NETCore.App”: {“version”: “1.1.0”,“type”: “platform”}}},In this case, you will develop using the new structure of solution but the framework will be the Full Framework.
          • Anonymous
            February 06, 2017
            The comment has been removed