ILMerge错误 Windows Phone 8未解决的程序集引用

3
我正在尝试使用 ILMerge.exe (2.12.0803) 合并一些用于 Windows Phone 8 的 .net 程序集。所有程序集本身都可以正常工作。我可以成功合并不包含对 Windows.Networking 命名空间的引用的程序集,如下所示:
.\ILMerge.exe /lib:"%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0" /out:.\WP8\%1\MathToolbox.dll .\%1\MathBase.dll .\%1\PolyFunctions.dll
但是,一旦我尝试包含使用 Windows.Networking 命名空间的 DLL,就会出现以下异常:
An exception occurred during merging: Unresolved assembly reference not allowed: Windows. at System.Compiler.Ir2md.GetAssemblyRefIndex(AssemblyNode assembly) at System.Compiler.Ir2md.GetTypeRefIndex(TypeNode type) at System.Compiler.Ir2md.VisitReferencedType(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 delayS ign, String keyFileName, String keyName) at System.Compiler.Writer.WritePE(CompilerParameters compilerParameters, Module module) at ILMerging.ILMerge.Merge() at ILMerging.ILMerge.Main(String[] args)
经过一些阅读,这个异常表明 ILMerge 无法定位 Windows.Networking 程序集。我尝试添加各种不同的标志到 ILMERGE 中,包括:
.\ILMerge.exe /lib:"%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\WindowsPhone\v8.0" /targetplatform:v4,"%ProgramFiles(x86)%\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone71" /out:.\WP8\%1\MathToolbox.dll .\%1\MathBase.dll .\%1\PolyFunctions.dll .\%1\RemoteTools.dll
但仍然得到相同的异常。如果有任何建议,将不胜感激。
2个回答

2

我认为ILMerge实际上只适用于纯.NET程序集,特别是当Windows Phone 8和WinRT项目使用引用的本地库时 - 这可能是找不到"Windows"未解决的程序集。


我也考虑过类似的想法,但我在使用Windows Phone SDK中其他命名空间时已经工作了,例如MathBase.dll,尽管它不是Windows.xxx命名空间的一部分。我假设所有WP8命名空间都出自同一源头,但可能并非如此。 - MarcF
我接受你的答案,因为似乎没有其他人有任何额外的反馈。我会假设我之所以会出现这个错误是因为我正在引用 WP8 的本地库,而正如你所建议的那样,ILMerge 还没有跟上。 - MarcF

2
错误表明ILMerge无法找到平台的Windows.winmd。在编译Windows Phone或Windows Store项目时,需要编译两个主要组件:平台SDK(WinRT)和.NET SDK。任何运行在这些程序集上的工具都需要这两个组件。
除了传递.NET程序集文件夹外,尝试将“C:\Program Files (x86)\Windows Phone Kits\8.0\Windows Metadata directory”作为lib参数传递。
请注意,ILMerge基于较旧版本的CCI(http://ccimetadata.codeplex.com/),因此即使完成上述操作,仍可能难以使用WinRT元数据格式,该格式与.NET略有不同。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接