Asp.net 不允许未解析的程序集引用:System.Web.Http使用ilmerge

Asp.net 不允许未解析的程序集引用:System.Web.Http使用ilmerge,asp.net,visual-studio-2017,ilmerge,Asp.net,Visual Studio 2017,Ilmerge,我正在尝试合并我的visual studio 2017项目的两个dll文件,并使用下面的命令行尝试了所有操作,但在合并它们时没有任何效果 请帮我解决这个问题 以下是我的计算机上安装的程序集: 这是ILMerge的安装路径 IlMerge.exe.config文件: <?xml version ="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true">

我正在尝试合并我的visual studio 2017项目的两个dll文件,并使用下面的命令行尝试了所有操作,但在合并它们时没有任何效果

请帮我解决这个问题

以下是我的计算机上安装的程序集:

这是ILMerge的安装路径

IlMerge.exe.config文件

<?xml version ="1.0"?>
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
  </startup>
</configuration>
例外情况:

LMerge.exe /targetplatform:4.0,"C:\Windows\Microsoft.NET\Framework64\v4.0.30319" /out:C:\Users\XXX\Desktop\XXX\client.dll C:\Users\XXX\Desktop\XXX\lib1.dll C:\Users\XXX\Desktop\XXX\lib2.dll
An exception occurred during merging:
Unresolved assembly reference not allowed: System.Web.Http.
   at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly)
   at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type)
   at System.Compiler.Ir2md.VisitClass(Class Class)
   at System.Compiler.Ir2md.VisitModule(Module module)
   at System.Compiler.Ir2md.SetupMetadataWriter(String debugSymbolsLocation)
   at System.Compiler.Ir2md.WritePE(Module module, String debugSymbolsLocation,
BinaryWriter writer)
   at System.Compiler.Writer.WritePE(String location, Boolean writeDebugSymbols,
 Module module, Boolean delaySign, String keyFileName, String keyName)
   at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Modu
le module)
   at ILMerging.ILMerge.Merge()
   at ILMerging.ILMerge.Main(String[] args)

试试看,有一个简单的解决办法。只需将/targetplatform:v4、[dotnet path]参数添加到ILMerge构建命令中即可。对我来说,框架路径是:

C:\Windows\Microsoft.NET\Framework\v4.0.30319 t完整合并命令应如下所示:

ilmerge/targetplatform:v4,“C:\Windows\Microsoft.NET\Framework\v4.0.30319”/out:“C.exe”“a.exe”“b.dll” 这应该可以解决问题


尝试运行每个具有管理权限的命令。

@downvoter-请在downvoting之前发表评论。是你不明白我上面写的东西还是别的。。让我知道我会努力改进itILMerge现在在GitHub是开源的,所以这样的问题应该直接问到那里,它已经是一个很久没有更新的工具了,而且开源后的修补进度也不快。因此,如果确实要合并某些内容,ILRepack是更好的选择。@LexLi-即使使用ILRepack,同样的错误仍然存在。在VS中构建多项目解决方案时,ILRepack出现此错误,并且某些项目使用“相同”DLL。我猜VS在发现多个项目需要相同的引用时,会使用ILMerge来合并程序集。对于我的特殊情况,错误似乎是由某些DLL在某些方面可能不匹配引起的。删除引用并确保为相应的项目重新添加完全相同的DLL可以解决我的问题。