How to force ASP.Net 5 application to use class libraries?

Step 1: Open VS 2015 RC and create a new "ASP.Net Web Application", enter image description hereenter image description here Step 2. Right-click the solution, add new windows "Class Library" (regular, not "Class Library (package)", enter image description here

Step 3: Put the method in Class1.cs in the class library. No matter what.

Step 4: Right-click the "Links" in the web project and add a link to your class library. enter image description here

Step 5: From the code file in the web project, call the method that you created in Class1.cs

So for me Class1.cs looks like this:

public class Class1
{
    public void X()
    {

    }
}

And I added the code in the web application as follows:

        var x = new ClassLibrary1.Class1();
        x.X();

Step 6: try to compile, you will get this error:

CS0246 ClassLibrary1 ( using ?)

, ( ) ASP.Net 5?

+4
1

:

C:\REDACTED\AspNet5Test\src\AspNet5Test\Startup.cs(26,25,26,38): DNX Core 5.0 error CS0246: The type or namespace name 'ClassLibrary1' could not be found (are you missing a using directive or an assembly reference?)

, DNX Core 5.0 -.Net 4.5 (, ClassLibrary1) .Net Core.

- dnxcore50 project.json.

:

"frameworks": {
    "dnx451": {
        "dependencies": {
            "ClassLibrary1": "1.0.0-*"
        }
    },
    "dnxcore50": { }
},

:

"frameworks": {
    "dnx451": {
        "dependencies": {
            "ClassLibrary1": "1.0.0-*"
        }
    }
},
+3

All Articles