Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Cannot Run MVC6 App with dnx46 as a Framework with Reference to 4.6 Library #2365

Closed
MisterJames opened this issue Jul 28, 2015 · 2 comments
Closed

Comments

@MisterJames
Copy link

However, I am trying to use a project that was created with :

  1. Updated global.json
  2. Updated project.json (bumped all assemblies to Beta6)
  3. Deleted/regenerated project.json.lock
  4. Corrected EF errors (namespace moves, ValueGeneratedOnAdd, etc)
  5. Removed ErrorPageOptions.ShowAll from middleware config

The app runs at this point. But I have the need to consume a 4.6 library, so, I:

  1. Add a new ClassLibrary to the solution (Windows class library, targeting 4.6)
  2. Add a reference from MVC project to ClassLibrary
  3. Set framework to dnx46 in project.json

After saving project.json, references under dnx46 update correctly and restore.

At this point, I can no longer run the app. If I start with a debugger, I get a 500. If I start without debugging, I get the following:

The current runtime target framework is not compatible with 'WebApplication6'.

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

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

Installed, active/default on my machine:

Active Version     Runtime Architecture OperatingSystem Alias
------ -------     ------- ------------ --------------- -----
       1.0.0-beta5 clr     x64          win
       1.0.0-beta5 clr     x86          win
       1.0.0-beta5 coreclr x64          win
       1.0.0-beta5 coreclr x86          win
       1.0.0-beta6 clr     x64          win
  *    1.0.0-beta6 clr     x86          win             default
       1.0.0-beta6 coreclr x64          win
       1.0.0-beta6 coreclr x86          win

Are there other bits I need to touch to get dnx46 working?

@MisterJames
Copy link
Author

Looks like the wrap was correctly generated:

{
  "version": "1.0.0-*",
  "frameworks": {
    "net46": {
      "wrappedProject": "../../src/ClassLibrary1/ClassLibrary1.csproj",
      "bin": {
        "assembly": "../../src/ClassLibrary1/obj/{configuration}/ClassLibrary1.dll",
        "pdb": "../../src/ClassLibrary1/obj/{configuration}/ClassLibrary1.pdb"
      }
    }
  }
}

Solution layout looks like the following:
image

And here's the relevant bits from the project.json:

  "version": "1.0.0-*",
  ...
  "frameworks": {
    "dnx46": {
      "dependencies": {
        "ClassLibrary1": "1.0.0-*"
      }
    }
  },

And global.json looks like the following:

{
  "projects": [
    "src",
    "test",
    "wrap"
  ],
  "sdk": {
    "version": "1.0.0-beta6"
  }
}

Finally - and not sure if this helps - when I remove the DLL from the project, remove the dependency from project.json, and move back to dnx451, I noticed this warning:
Warning The primary reference "C:\Users\James\Documents\Visual Studio 2015\Projects\WebApplication6\src\ClassLibrary1\bin\Debug\ClassLibrary1.dll" could not be resolved because it was built against the ".NETFramework,Version=v4.6" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5". WebApplication6 C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets 1819

@MisterJames
Copy link
Author

Closing because I have a way easier repro.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant