I'm porting a solution from MSVS2005 to MSVS2012. The projects are in C++ .NET but use homemade native C++ libraires too. We had no problem building the projects with 2005 but now, I'm unable to build a project using 2012. I get the following error message:
MyFile.obj : error LNK2022: metadata operation failed (801311E4) : Duplicate managed types have different visibilities.
What does this mean? What info do you need to help me?
Thanks for your help?
I had the same problem, and indeed had the same condition described in dom_beau's answer, so I'm pretty sure I had the same underlying cause as well. However, to be able to resolve the error, I had to find the actual offending classes (there were a few, and the error messages do little to help you find them!).
So I wrote the following LINQ query which finds all classes defined in multiple *.obj files with conflicting visibilities. It may be useful to someone, so I'm posting it here.
// Analyze text files produced by ildasm when given *.obj files.
// Use "for %1 in (*.obj) do ildasm /text %1 > %1-ildasm.txt" to produce the files.
from file in Directory.GetFiles(@"your project's intermediate folder")
where file.EndsWith("-ildasm.txt")
let lines = File.ReadAllLines(file)
from i in Enumerable.Range(0, lines.Count() - 1)
where lines[i].Contains("TypDefName:")
let type = lines[i].Substring(16,lines[i].IndexOf(" (")-17)
let flags = lines[i+1]
group new {file, flags} by type into g
where g.Select(t=>t.flags).Distinct().Count() > 1
select g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With