Duplicate assembly MetadataToken

32 views
Skip to first unread message

digitalio Q

unread,
Feb 4, 2020, 8:02:38 PM2/4/20
to mono-cecil
I'm trying to add an assembly reference to a module using the following code, and it ends up with more than one assembly references having the same MetadataToken value; any ideas what might be wrong?

        public static IMetadataScope Import(this ModuleDefinition target, AssemblyNameReference assembly)
        {
            var res = target.AssemblyReferences.FirstOrDefault(cur => cur.FullName.Equals(assembly.FullName));
            if (res != null)
                return res;

            res = new AssemblyNameReference(assembly.Name, assembly.Version)
            {
                PublicKeyToken = assembly.PublicKeyToken,
            };
            target.AssemblyReferences.Add(res);
            return res;
        }

Reply all
Reply to author
Forward
0 new messages