c# - Error 2 The type <T> exists in both... with ILMerge -
i have 3 projects:
- a_mainproject (startup project)
- b_intermediateproject
- c_sharedclasslibrary
the depencies are:
a depends on b & c
b depends on c
and c depends on system only.
every project has it's own namespace.
as long no ilmerge installed, works fine.
if ilmerge activated project ("a_mainproject") still works fine , 1 self-contained executable project generated.
if ilmerge activated b_intermediateproject, following error:
error 2 type 'c_sharedclasslibrary.sharedclass' exists in both 'c:\dev\ilmergeerror\b_intermediateproject\bin\debug\b_intermediateproject.exe' , 'c:\dev\ilmergeerror\c_sharedclasslibrary\bin\debug\c_sharedclasslibrary.dll' c:\dev\ilmergeerror\a_mainproject\program.cs 12 a_mainproject
i use "msbuild ilmerge task" 1.0.3-rc2 "ilmerge" 2.13.0307 (from mbarnett).
the minimal solution contains 3 projects 1 class each. version has ilmerge activated on 1 project , works:
this version has activated on project b , produces error:
if merge 2 exes , dll ilmerge externally (ilmergegui) works fine.
thank in advance answering, xan-kun
the short answer should enable ilmerge on a, it'll merge both a+b+c together.
the reason why hit error when enable ilmerge on b, b repacked c types (b' = b+c). hence when ilmerge triggers on a, it'll merge a+b'+c = a+(b+c)+c
now 2 scenarios can happen:
b uses c internally, , doesn't (publicly) expose c type (e.g. method argument or return value). in case can make work through ilmerge options (/internalize on b , /allowdup on a), though you'll end twice every c type in merged assembly a.
b exposes c types, maybe used a. in case if manage make merge work, it'll fail @ runtime, because , b' reference different types (e.g. class c, b' references b'.c , references c.c), , you'll nasty type cast exceptions, because 2 different types (same name, same namespace, different assemblies).
(they're nasty because don't indicate assembly mismatch, , exception says "c cannot cast c", can confusing many)
Comments
Post a Comment