Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Legacy assembly reference error in asp.net-vnext

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-*"
        }
    }
},
like image 876
Ullas Prabhu Avatar asked Oct 19 '22 18:10

Ullas Prabhu


2 Answers

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.

Question 1, Question 2

like image 121
Son_of_Sam Avatar answered Oct 22 '22 19:10

Son_of_Sam


Add the library to frameworkDependencies not dependencies

"net45": {
    "frameworkAssemblies": {
        "components": "1.0.0"
    },
    "dependencies": {
        // NuGet packages go here
    }
like image 30
Victor Hurdugaci Avatar answered Oct 22 '22 21:10

Victor Hurdugaci