Reputation: 239
I am using VS2015 CTP5 and I am referencing a legacy class library compiled with 4.5.1. During compile, I get this warning:
The primary reference "D:\components.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.5.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".
Here is my project.json after adding the reference
"frameworks": {
"aspnet50": {
"dependencies": {
"components": "1.0.0-*"
}
}
},
Upvotes: 5
Views: 1268
Reputation: 809
For me, none of the above worked and after spending a lot of hours investigating... I finally found a solution!
I have to create a new package in the NuGet Package Explorer for my dll, save and export it to a local folder (use the File->Save and File->Export commands). Then declare my local repository(folder) to Visual Studio, go to Tools->Options->NuGet Package Manager->Package Sources and insert a record for my local repository - see image below.
Upvotes: 0
Reputation: 1943
Since the "component" library is build for .net 45 and assuming that you build that library in an older version of visual studio, it will not work in aspnetcore5 but will work on aspnet5 (these are the new version for .net). if you want to get rid of the error and still use your component library, you will need remove the aspnetcore5 json node from the project.json file but the project that you building will not be compatible with aspnetcore5. So your project.json file for the frameworks section should look like this.
"frameworks": {
"aspnet50": {
"frameworkAssemblies": {
"System": "4.0.0.0"
},
"dependencies": {
}
},
"net45": {
"dependencies": { "components": "1.0.0"},
"frameworkAssemblies": { }
}
}
And your reference should look like, I have warning sing next to the component library because I don't have that in my code.
You can look at this question to get more information.
Upvotes: 2
Reputation: 28425
Add the library to frameworkDependencies
not dependencies
"net45": {
"frameworkAssemblies": {
"components": "1.0.0"
},
"dependencies": {
// NuGet packages go here
}
Upvotes: 1