3

Where to begin... This has had me all day.

I have updated my projects to use the new ASP.NET 5 Empty Preview Template.

I have managed to get all my projects building, but when i run my website, i get this error

The current runtime target framework is not compatible with 'MY.WEB.NAMESPACE'.

Current runtime Target Framework: 'DNX,Version=v4.5.1 (dnx451)' Type: CLR Architecture: x86 Version: 1.0.0-beta5-12103

Please make sure the runtime matches a framework specified in project.json

All the examples i have seen so far, seem to have both EntityFramework in the same project, but i am using EntityFramework (currently version 6), in a separate project. My Projects are as follows

Infrastructure - Helpful functions, referenced by any project

Entities - My POCO objects

Data - My DbContext class and other Database specific code

Service - My services to add/update entities, also references SimpleValidation for my validation

Web - My web application, which consists of WebApi and angularJs.

Now i have a project.json file for each project, which looks like so

INFRASTRUCTURE

{
    "version": "1.0.0-*",
    "description": "my.namespace.Infrastructure",
    "authors": [ "me" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",

    "dependencies": {
        "System.Collections": "4.0.11-beta-23225",
        "System.Linq": "4.0.1-beta-23225",
        "System.Threading": "4.0.11-beta-23225",
        "System.Runtime": "4.0.21-beta-23225",
        "Microsoft.CSharp": "4.0.1-beta-23225",
        "Humanizer": "1.37.7"
    },

    "frameworks": {
        "net46": { }
    }
}

ENTITES (POCOS)

{
    "version": "1.0.0-*",
    "description": "my.namespace.Entities",
    "authors": [ "me" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",

    "dependencies": {
        "System.Collections": "4.0.11-beta-23225",
        "System.Linq": "4.0.1-beta-23225",
        "System.Threading": "4.0.11-beta-23225",
        "System.Runtime": "4.0.21-beta-23225",
        "Microsoft.CSharp": "4.0.1-beta-23225"
    },

    "frameworks": {
        "net46": { }
    }
}

DATA (DBCONTEXT)

{
    "version": "1.0.0-*",
    "description": "my.namespace.Data",
    "authors": [ "me" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",

    "dependencies": {
        "System.Collections": "4.0.11-beta-23225",
        "System.Linq": "4.0.1-beta-23225",
        "System.Threading": "4.0.11-beta-23225",
        "System.Runtime": "4.0.21-beta-23225",
        "Microsoft.CSharp": "4.0.1-beta-23225",
        "DbExtensions": "5.1.0",
        "my.namespace.Entities": "1.0.0-*",
        "my.namespace.Infrastructure": "1.0.0-*",
        "EntityFramework": "6.1.3"
    },

    "frameworks": {
        "net46": { }
    }
}

SERVICE

{
    "version": "1.0.0-*",
    "description": "my.namespace.Service",
    "authors": [ "me" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",

    "dependencies": {
        "System.Collections": "4.0.10-beta-23019",
        "System.Linq": "4.0.0-beta-23019",
        "System.Threading": "4.0.10-beta-23019",
        "System.Runtime": "4.0.10-beta-23019",
        "Microsoft.CSharp": "4.0.0-beta-23019",
        "FluentValidation": "5.6.2",
        "my.namespace.Entities": "1.0.0-*",
        "my.namespace.Data": "1.0.0-*",
        "my.namespace.Infrastructure": "1.0.0-*",
        "ncalc": "1.3.8"
    },

    "frameworks": {
        "net46": { }
    }
}

My web application, project.json looks like this

{
    "webroot": "wwwroot",
    "version": "1.0.0-*",
    "description": "my.namespace.Web",
    "authors": [ "me" ],

    "dependencies": {
        "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
        "Microsoft.AspNet.Mvc": "6.0.0-beta5",
        "AutoMapper": "4.0.4"
    },

    "commands": {
        "web": "Microsoft.AspNet.Hosting --config hosting.ini"
    },

    "frameworks": {
        "dnx5": {
            "dependencies": {
                "my.namespace.Infrastructure": "1.0.0-*",
                "my.namespace.Entities": "1.0.0-*",
                "my.namespace.Data": "1.0.0-*",
                "my.namespace.Service": "1.0.0-*"
            }
        }
    },

    "publishExclude": [
        "node_modules",
        "bower_components",
        "**.xproj",
        "**.user",
        "**.vspscc"
    ],
    "exclude": [
        "wwwroot",
        "node_modules",
        "bower_components"
    ]
}

Now this all seems to build fine, with no errors, but when i try to run, i get the above message. I saw another post here which suggests adding an environment variable, but this doesnt seem to work.

If i remove all the references to my other projects, comment out all code that references the other projects, and then change frameworks tag to this, the site loads.

"frameworks": {
    "dnx45": {
        "dependencies": {

        }
    }
},

Any help would be greatly appreciated.

EDIT.

Here is my project properties

enter image description here

When i change to dnxcore5, i get this

enter image description here

EDIT 2:

I have updated all my projects to use dnx50 and dropped dnxcore50. I still get the same error. It must be something to do with my installation....But what i have no idea...

Community
  • 1
  • 1
Gillardo
  • 9,518
  • 18
  • 73
  • 141
  • Can't you change the `frameworks` item to use `dnx45` instead of `dnx5` but keep the dependencies? – DavidG Oct 09 '15 at 14:35
  • If i change the web application framworks to dnx45, from dnx5 (or even dnx46) my project wont build and throws 1974 errors. Stupid things too, like 'object' does not contain a constructor that takes 0 arguments, and Predefined type 'System.Boolean' is not defined or imported – Gillardo Oct 09 '15 at 15:11
  • If i change it to dnx46, it builds, but i get the same error as before – Gillardo Oct 09 '15 at 15:13
  • I could be mistaken (don't have access to a project at the moment) but shouldn't the v5 one actually be `dnxcore50` or something similar? – DavidG Oct 09 '15 at 15:14
  • Changing it to dnxcore shows errors when referencing my other projects, i have added screenshot for you to see – Gillardo Oct 09 '15 at 15:20
  • You can add both frameworks, I think like this: `"frameworks": { "dnx451": { }, "dnxcore50": { } }` – DavidG Oct 09 '15 at 15:24
  • Nope, still dont work. Again get lots of stupid errors. I think it because dnxcore50 doesnt reference my other projects, but if i add them, i get the "invalid" icon next to each project, like in the screen i have added above – Gillardo Oct 09 '15 at 15:45

3 Answers3

4

First target dnx-clr-win-x86 (most likely beta5 in your case) since you want to run this on IIS with Entity Framework. Check your solution properties. Also have a look at global.json in your Solution Items folder. Please note that runtime targets clr.

"sdk": {
    "version": "1.0.0-beta5",
    "runtime": "clr",
    "architecture": "x86"
}

Change dnx5 (this doesn't exist) to dnx46 and remove dnxcore50 from all project.json files.

"frameworks": {
    "dnx46": {
        "dependencies": {}
    }
},

Add an environment variable to your web project "DNX_IIS_RUNTIME_FRAMEWORK" : "DNX46"

A side note, beta7 is already out and I suggest you use that rather than beta5 and also remember to upgrade your dnvm.

Nick De Beer
  • 5,232
  • 6
  • 35
  • 50
1

dnx5 is not a thing - you're specifying a framework that doesn't exist.

When you change it to dnxcore50, you are getting fails because a project that only targets the coreclr cannot reference libraries targeting the clr (net46). Regardless, the coreclr is not feature complete yet and last time I checked it didn't yet implement System.Data.Sql, so you can't run Entity Framework on it yet anyway.

You should first determine which frameworks you want to run your application on, target them only, and then work on fixing your dependencies.

Stafford Williams
  • 9,696
  • 8
  • 50
  • 101
  • I want/need to run this on iis on windows servers, apart from development with will still run on a windows machine. I would like to use asp.net5. Do i need to target coreclr? – Gillardo Oct 10 '15 at 06:16
  • You do not need to target coreclr. Remove all dnxcore50. You should target dnx451 on the MVC application. Also, because you are hosting on IIS and only targeting dnx451, you don't need to update your other projects to be xproj, you could just keep them as csproj and reference them fine from the MVC application - targeting them at the 4.5 runtime if neccessary. I note you are using Entity Framework 6 - if you are expecting to also use AspNet identity you are going to run into more problems though... – Stafford Williams Oct 10 '15 at 07:34
0

Try using "Install-Package EntityFramework.MicrosoftSqlServer –Pre". Worked for me.