Why does peverify give me an "unable to resolve token" error for plain and simple managed code?

84 views Asked by At

I wonder why peverify /quiet gives me this error:

[IL]: Error :[QuickFIXn.xyz.dll : QuickFIXn.MessageFactories+DefaultMessageFactory::GetTransportDataDictionary][offset 0x00000039] Unable to resolve token.

for this piece of managed code (omitting unrelated methods and fields):

namespace QuickFIXn
{
    public static class MessageFactories
    {
        ...
        internal class DefaultMessageFactory : IMessageFactory
        {
            private readonly System.Collections.Generic.Dictionary<string, IMessageFactory> _factories = new System.Collections.Generic.Dictionary<string, IMessageFactory>();
            ...
            public DataDictionary.DataDictionary GetTransportDataDictionary(string beginString)
            {
                IMessageFactory f;

                // FIXME: This is a hack.  FIXT11 could mean 50 or 50sp1 or 50sp2.
                // We need some way to choose which 50 version it is.
                if (beginString.Equals(FixValues.BeginString.FIXT11))
                {
                    f = _factories["FIX50"];
                } else if (!_factories.TryGetValue(beginString, out f))
                    throw new UnsupportedVersion(beginString);

                return f.GetTransportDataDictionary(beginString);
            }
        }
    }
}

ildasm for the method looks like this:

.method public hidebysig newslot virtual final 
        instance class [QuickFIXn]QuickFIXn.DataDictionary.DataDictionary 
        GetTransportDataDictionary(string beginString) cil managed
{
  // code size       63 (0x3f)
  .maxstack  3
  .locals init ([0] class [QuickFIXn]QuickFIXn.IMessageFactory f)
  IL_0000:  ldarg.1
  IL_0001:  ldstr      "FIXT.1.1"
  IL_0006:  callvirt   instance bool [mscorlib]System.String::Equals(string)
  IL_000b:  brfalse.s  IL_0020

  IL_000d:  ldarg.0
  IL_000e:  ldfld      class [mscorlib]System.Collections.Generic.Dictionary`2<string,class [QuickFIXn]QuickFIXn.IMessageFactory> QuickFIXn.MessageFactories/DefaultMessageFactory::_factories
  IL_0013:  ldstr      "FIX50"
  IL_0018:  callvirt   instance !1 class [mscorlib]System.Collections.Generic.Dictionary`2<string,class [QuickFIXn]QuickFIXn.IMessageFactory>::get_Item(!0)
  IL_001d:  stloc.0
  IL_001e:  br.s       IL_0037

  IL_0020:  ldarg.0
  IL_0021:  ldfld      class [mscorlib]System.Collections.Generic.Dictionary`2<string,class [QuickFIXn]QuickFIXn.IMessageFactory> QuickFIXn.MessageFactories/DefaultMessageFactory::_factories
  IL_0026:  ldarg.1
  IL_0027:  ldloca.s   f
  IL_0029:  callvirt   instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,class [QuickFIXn]QuickFIXn.IMessageFactory>::TryGetValue(!0,
                                                                                                                                                              !1&)
  IL_002e:  brtrue.s   IL_0037

  IL_0030:  ldarg.1
  IL_0031:  newobj     instance void [QuickFIXn]QuickFIXn.UnsupportedVersion::.ctor(string)
  IL_0036:  throw

  IL_0037:  ldloc.0
  IL_0038:  ldarg.1
  IL_0039:  callvirt   instance class [QuickFIXn]QuickFIXn.DataDictionary.DataDictionary [QuickFIXn]QuickFIXn.IMessageFactory::GetTransportDataDictionary(string)
  IL_003e:  ret
} // end of method DefaultMessageFactory::GetTransportDataDictionary

Is something wrong with the code - or with peverify?

Edit: As this question came up in a comment: There is no default interface implementation:

namespace QuickFIXn
{
    public interface IMessageFactory
    {
        DataDictionary.DataDictionary GetTransportDataDictionary(string beginString);
        ...
    }
0

There are 0 answers