Here's the updated code that I'm using to emit the Singleton<,> call:
// Call the Singelton<TFactory, TService>.Instance
var genericSingletonType = module.Import(typeof
(Singleton<,>));
var serviceTypeParameter =
genericSingletonType.GenericParameters[1];
var singletonType = new GenericInstanceType
(genericSingletonType);
singletonType.GenericArguments.Add(creatorType);
singletonType.GenericArguments.Add(serviceType);
var getInstanceMethod = new MethodReference
("get_Instance", singletonType, serviceTypeParameter, false, false,
MethodCallingConvention.Default);
module.MemberReferences.Add(getInstanceMethod);
IL.Emit(OpCodes.Call, getInstanceMethod);
The problem is that PEVerify keeps reporting "Unable to resolve
token". Is there something that I'm doing wrong here?