具有相同标识"XXX"的装配体已被导入.尝试删除重复的引用之一 [英] An assembly with the same identity 'XXX' has already been imported. Try removing one of the duplicate references

查看:149
本文介绍了具有相同标识"XXX"的装配体已被导入.尝试删除重复的引用之一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MVC Web应用程序,可以使用msbuild命令行发布到我们的UAT服务器.它托管在Windows 2016服务器IIS 10上.

I have a MVC web application that I publish to our UAT server with msbuild command line. It is hosted on a windows 2016 server, IIS 10.

有时候,并不总是,当我尝试启动网站时出现以下错误:

Sometimes, not always, I have a the following error when I try to start up the website:

"/"应用程序中的服务器错误. 编译错误 说明:编译服务该请求所需的资源期间发生错误.请查看以下特定的错误详细信息,并适当地修改您的源代码.

Server Error in '/' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

编译器错误消息:CS1703:具有相同标识'System.Xml.ReaderWriter,版本= 4.1.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a'的程序集已经导入.尝试删除重复的引用之一.

Compiler Error Message: CS1703: An assembly with the same identity 'System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' has already been imported. Try removing one of the duplicate references.

源错误: [没有相关的源代码行] 源文件:行:0 显示详细的编译器输出: C:\ WINDOWS \ SysWOW64 \ inetsrv> "C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ csc.exe"/t:library/utf8output/R: "C:\ WINDOWS \ Microsoft.Net \ assembly \ GAC_MSIL \ System.Text.Encoding.Extensions \ v4.0_4.0.0.0__b03f5f7f11d50a3a \ System.Text.Encoding.Extensions.dll"/R:

Source Error: [No relevant source lines] Source File: Line: 0 Show Detailed Compiler Output: C:\WINDOWS\SysWOW64\inetsrv> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R: "C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Text.Encoding.Extensions\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Text.Encoding.Extensions.dll" /R:

...

"C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET Files \ root \ 4a1a5bcc \ 84ed54d3 \ assembly \ dl3 \ ab6a43c3 \ 00602620_2137d201 \ System.Xml.ReaderWriter.dll"/R:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a1a5bcc\84ed54d3\assembly\dl3\ab6a43c3\00602620_2137d201\System.Xml.ReaderWriter.dll" /R:

...

"C:\ WINDOWS \ Microsoft.Net \ assembly \ GAC_MSIL \ System.Xml.ReaderWriter \ v4.0_4.0.0.0__b03f5f7f11d50a3a \ System.Xml.ReaderWriter.dll"/R:

"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.ReaderWriter\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Xml.ReaderWriter.dll" /R:

...

"C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET Files \ root \ 4a1a5bcc \ 84ed54d3 \ App_Web_home.cshtml.65a2d1ee.ef3qnjdl.1.cs" Microsoft(R)Visual C#编译器版本4.6.1586.0

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a1a5bcc\84ed54d3\App_Web_home.cshtml.65a2d1ee.ef3qnjdl.1.cs" Microsoft (R) Visual C# Compiler version 4.6.1586.0

对于C#5 版权所有(C)Microsoft Corporation.保留所有权利.

for C# 5 Copyright (C) Microsoft Corporation. All rights reserved.

此编译器作为Microsoft(R).NET Framework的一部分提供,但仅支持C#5以下的语言版本,该语言版本不再是最新版本.对于支持较新版本的C#编程语言的编译器,请参见 http://go.microsoft. com/fwlink/?LinkID = 533240

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest version. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

c:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET Files \ root \ 4a1a5bcc \ 84ed54d3 \ assembly \ dl3 \ ab6a43c3 \ 00602620_2137d201 \ System.Xml.ReaderWriter.DLL:错误CS1703:An具有相同标识'System.Xml.ReaderWriter,版本= 4.1.0.0,区域性=中性,PublicKeyToken = b03f5f7f11d50a3a'的程序集已经导入.尝试删除重复的引用之一. c:\ Windows \ Microsoft.NET \ assembly \ GAC_MSIL \ System.Xml.ReaderWriter \ v4.0_4.0.0.0__b03f5f7f11d50a3a \ System.Xml.ReaderWriter.dll:(与先前错误相关的符号位置)

c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a1a5bcc\84ed54d3\assembly\dl3\ab6a43c3\00602620_2137d201\System.Xml.ReaderWriter.DLL: error CS1703: An assembly with the same identity 'System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' has already been imported. Try removing one of the duplicate references. c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Xml.ReaderWriter\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Xml.ReaderWriter.dll: (Location of symbol related to previous error)

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.7.3163.0

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3163.0

我试图查找参考,但是在web.config中只能看到一次.

I have tried to look for references, but I can see it only once in the web.config.

此外,运行iisreset或重新启动Web服务器后,错误通常会消失. 我担心如果我们释放它,也可能在实时服务器上发生这种情况.

Also, the error usually goes away after I run an iisreset or restart the web server. My fear is this could happen on the live server too if we release it.

希望能为我指出正确的方向进行修复.

I would appreciate any help to point me to the right direction to fix this.

更新:

我已经检查了整个项目中的所有参考.我所能找到的是.

I have checked all the references in the whole project. All I can find is.

Web.config:

<compilation defaultLanguage="c#" debug="true" batch="false" targetFramework="4.5" numRecompilesBeforeAppRestart="50">
        <assemblies>
            <remove assembly="System.Xml.ReaderWriter" />
            <add assembly="System.Xml.ReaderWriter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

Packages.config:

<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net461" />

更新2:

我已经按照PéterCsajtai的建议从web.config中删除了添加程序集". 从那时起,它运行良好(可能没有在任何地方使用).

I have removed the "add assembly" from the web.config as suggested by Péter Csajtai. Since then it is working fine (probably it is not used anywhere).

我尝试删除其他程序集,但是使用了这些程序集,因此我需要多个重定向.另一方面,它正在工作,因此我不太愿意修复"它.我添加了重定向以查看它是否可以正常运行,但是如果没有错误,则很难判断它是否在做正确的事情.

I have tried to remove the other assemblies, but those are used, so I would need multiple redirects. On the other hand it is working, so I am reluctant a bit to "fix it". I have added a redirect to see if it would work, but without an error it is hard to tell if it is doing the right thing.

还找到了将来可能会对其他人进行故障排除有用.

Also found this that could be useful for other's for troubleshooting in the future.

推荐答案

作为输出状态,您的项目从两个不同的地方引用System.Xml.ReaderWriter.dll:

As the output states, your projects are referencing the System.Xml.ReaderWriter.dll from two different places:

C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \临时ASP.NET文件\ root \ 4a1a5bcc \ 84ed54d3 \ assembly \ dl3 \ ab6a43c3 \ 00602620_2137d201 \

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\4a1a5bcc\84ed54d3\assembly\dl3\ab6a43c3\00602620_2137d201\

并且来自GAC:

C:\ WINDOWS \ Microsoft.Net \ assembly \ GAC_MSIL \ System.Xml.ReaderWriter \ v4.0_4.0.0.0__b03f5f7f11d50a3a \

C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.ReaderWriter\v4.0_4.0.0.0__b03f5f7f11d50a3a\

您应该检查所有对该dll的引用,并统一引用路径不同的引用路径.

You should check all your references to that dll and unify the reference paths where they are different.

这篇关于具有相同标识"XXX"的装配体已被导入.尝试删除重复的引用之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆