Matthias Müller Matthias Müller - 9 days ago 4
C# Question

Why does adding Project-References break dependencies

I'm currently learning AngularJS2 using a very well done Project-Template for VS2015, which I found here: http://blog.stevensanderson.com/2016/10/04/angular2-template-for-visual-studio/.
Since I'm always a big fan of giving learning-apps some business value, I'd like to fetch some data of an database. So I created new .Net 4.6.1 assemblies, where I can add my businesslogic and the Entity Framework.

Well, as we all might know, I can't add a project reference from a .Net Core App to a Full-Stack .NET one. To fix this, I used the guide here: https://github.com/BradRem/AspNetCoreWithFrameworkLibrary/blob/master/AspNetCoreApp/ ,which basically suggests to switch the frameworks-tab in the project.json from

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},


To

"frameworks": {
"net46": {

}
},


Well, that was the beginning of my troubles:
It seems like I can only use .Net 4.6, not 4.6.1 or 4.6.2, otherwise the existing dependencies:

"Microsoft.AspNetCore.AngularServices": "1.0.0-*",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Unity": "4.0.1",
"NETStandard.Library": "1.6.1",
"CommonServiceLocator": "1.3.0"


Need to get updated. I tried to do these updates, but the NuGet updated the project.json in a way it wasn't usable anymore! So I had to re-create a project and copy the original project.json in order to make it work.
So, no big deal, I kept the Assembly-Versions to 4.6 and also set the framework in the project.json, but then it went strange: I could build the ASP.NET Core Project with the framework set to 4.6, but as soon as I added my assemblies:

"frameworks": {
"net46": {
"dependencies": {
"xx.PES.Logics": {
"target": "project"
},
"xx.PES.Model": {
"target": "project"
}
}
}
},


The other dependencies started to fail. For example:


Additional information: Could not load file or assembly
'Microsoft.Extensions.Logging.Abstractions, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its
dependencies. The located assembly's manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)


I had to remove the dependencies, clean(!) the bin folder manually, and then it worked again.

TLDR: Instead of doing what I wanted to, learning AngularJS2, all I'm doing is trying to make this dependency hell work. I also searched a bit for general documentations, what can be mixed, how the tags are working etc., but there doesn't seem to be much documentations arround.
Are there some best practices or findings documented, or is it basically just to early to use .NET-Core?

Answer

Full-Stack .NET

Agrrrrr, its naming .Net Framework. Dont make again that moster

If you have problem with packages i suggest restore by dotnet restore or in solution exploler by clicking References > Restore packages

Next thing. If you want add reference to other project you need to be sure to use the same or lower .Net what you are using in your main project