ILMerge StackOverflow异常

时间:2015-03-27 16:02:11

标签: stack-overflow ilmerge

我正在尝试运行ILMerge将我自己的程序集与三个第三方程序集结合起来。

var ilmerge = new ILMerging.ILMerge();

ilmerge.SetInputAssemblies(new string[] {
    @"C:\dev\MyAssembly.dll",
    @"C:\dev\Nest.dll",
    @"C:\dev\Elasticsearch.Net.dll",
    @"C:\dev\Newtonsoft.Json.dll"
});

ilmerge.OutputFile = @"C:\dev\MyAssembly.Merged.dll";

ilmerge.Merge();

我得到以下异常

An unhandled exception of type 'System.StackOverflowException' occurred in ILMerge.exe

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

就我而言,Stephen Cleary的blog post给出了答案。应使用.SetTargetPlatform(string, string);方法,如下所示。

var ilmerge = new ILMerging.ILMerge();

ilmerge.SetInputAssemblies(new string[] {
    @"C:\dev\MyAssembly.dll",
    @"C:\dev\Nest.dll",
    @"C:\dev\Elasticsearch.Net.dll",
    @"C:\dev\Newtonsoft.Json.dll"
});

ilmerge.SetTargetPlatform("v4", @"C:\Windows\Microsoft.NET\Framework\v4.0.30319");

ilmerge.OutputFile = @"C:\dev\MyAssembly.Merged.dll";

ilmerge.Merge();