ASP .NET 5 MVC 6 beta 7升级:“具有同等身份的多个程序集”问题

时间:2015-09-14 09:22:01

标签: c# asp.net asp.net-mvc dnx

目前正在尝试从ASP .NET 5 MVC 6的beta 6升级到beta 7。 我按照此处详述的步骤进行了操作:How to upgrade ASP.NET 5 from Beta6 to Beta7但我仍然有程序集问题:

Multiple assemblies with equivalent identity have been imported: '<in-memory-assembly>' and '<in-memory-assembly>'. Remove one of the duplicate references.

This blog提供了一些解决问题的线索,但不幸的是与我的项目不符。

我知道它链接到project.json中的包列表。一些解决方案建议使用Microsoft.Framework.Runtime.Abstractions,但我的列表中没有它。

我的项目有几个部分有时互相引用。装配问题发生在其中两个中,我认为它是链接的,因为每个错误出现8次。

以下是两个的project.json:

{
    "webroot": "wwwroot",
    "version": "1.0.0-*",
    "dependencies": {
        "EntityFramework.SqlServer": "7.0.0-beta7",
        "EntityFramework.Commands": "7.0.0-beta7",
        "EntityFramework.Core": "7.0.0-beta7",
        "Microsoft.AspNet.Mvc": "6.0.0-beta7",
        "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
        "Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
        "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
        "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
        "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
        "Microsoft.AspNet.Loader.IIS": "1.0.0-beta7",
        "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
        "Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
        "Microsoft.Framework.Configuration": "1.0.0-beta7",
        "Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
        "Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta5",
        "Microsoft.Framework.Logging": "1.0.0-beta7",
        "Microsoft.Framework.Logging.Console": "1.0.0-beta7",
        "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7",
        "SSI.Domain": "",
        "SSI.Service": "",
        "log4net": "2.0.3",
        "jQuery.UI.Themes.smoothness": "1.8.9",
        "SSI.WordDocumentGenerator.Client": "1.0.0-*"
    },
    "commands": {
        "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
        "gen": "Microsoft.Framework.CodeGeneration",
        "ef": "EntityFramework.Commands"
    },
    "frameworks": {
        "dnx451": {
            "frameworkAssemblies": {
                "System.DirectoryServices": {
                    "version": "",
                    "type": "build"
                },
                "System.DirectoryServices.AccountManagement": {
                    "version": "4.0.0.0",
                    "type": "build"
                }
            }
        }
    },
    "exclude": [
        "wwwroot",
        "node_modules",
        "bower_components"
    ],
    "publishExclude": [
        "node_modules",
        "bower_components",
        "**.xproj",
        "**.user",
        "**.vspscc"
    ],
    "compilationOptions": {
        "warningsAsErrors": true
    }
}

-

{
    "version": "1.0.0-*",
    "description": "",
    "authors": [ "author" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",

    "dependencies": {
        "SSI.Domain": "",
        "SSI.Service": "",
        "DocumentFormat.OpenXml": "2.5.0"
    },

    "frameworks": {
        "dnx451": {
            "dependencies": {
                "System.Collections": { "version": "4.0.0.0", "type": "build" },
                "System.Linq": { "version": "4.0.0-beta-23109", "type": "build" },
                "System.Threading": { "version": "4.0.10-beta-23109", "type": "build" },
                "Microsoft.CSharp": { "version": "4.0.0-beta-22816", "type": "build" }
            },
            "frameworkAssemblies": {
                "WindowsBase": { "version": "4.0.0.0", "type": "build" }
            }

        }
    }
}

我试图删除一些软件包,运行dnu恢复以查看错误是否仍然存在且始终存在,所以我开始没有想法......

2 个答案:

答案 0 :(得分:2)

在没有看到整个项目的情况下很难分辨,但我猜测第二个JSON片段来自你的库。我的猜测是,这是导致错误的库,而且只会报告到您的Web应用程序中。

以下是一些想法:

  • 将您的框架:dnx451:依赖项移动到框架中:dnx451:frameworkAssemblies。
  • 删除那些System。*包中的 -beta 标识(尝试抓取Nuget包而不是使用本地系统库的可能性很小)
  • 将System。*版本号更改为“4.0.0.0”
  • 切换到较不详细的参考语法(即删除“version”和“type”,只需在引号中指定类似“System.Linq”:“4.0.0.0”)
  • 删除Microsoft.CSharp

答案 1 :(得分:0)

I ran into this issue when I had added a class library to a web project. When I added the class library the project.json file frameworks looked like this ...

  "frameworks": {
    "dotnet": { }
  }

When I matched the frameworks of my web application the error was resolved.

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  }