anchor.diff:      raise EIoCException.Create(Format('An implementation for type %s with name %s is already registered with IoC',[pInfo.Name, newName]));
   end;
   
  -
  -
  -
  -
  -function TDUnitXIoC.Resolve<TInterface>(const name: string): TInterface;
  -var
  -  key   : string;
  +function TDUnitXIoC.Resolve<TInterface>(const name: string = ''; const AThrowOnFail : boolean = false): TInterface;
  +var
  +  resolveResult: TResolveResult;
  +  errorMsg : string;
     pInfo : PTypeInfo;
  -  rego  : TIoCRegistration<TInterface>;
  -  lcontainer : TDictionary<string,TObject>;
  -  res : IInterface;
  -  activator : TActivatorDelegate<TInterface>;
  -  o : TObject;
  -  newName : string;
  -begin
  -  newName := name;
  -
  -  result := Default(TInterface);
  +begin
     pInfo := TypeInfo(TInterface);
  -  if newName = '' then
  -    key := string(pInfo.Name)
  -  else
  -    key := string(pInfo.Name) + '_' + newName;
  -  key := LowerCase(key);
  -
  -  lcontainer := FContainerInfo;
  -
  -  if not lcontainer.TryGetValue(key,o) then
  -  begin
  -    exit(nil);
  -  end;
  -//    raise EIoCResolutionException.Create(Format('No implementation registered for type %s',[pInfo.Name]));
  -
  -  rego := TIoCRegistration<TInterface>(o);
  -
  -  if rego.IsSingleton then
  -  begin
  -    //If a singleton was registered with this interface then check if it's already been instanciated.
  -    if rego.Instance <> nil then
  +  resolveResult := InternalResolve<TInterface>(result, name);
  +
  +  //If we don't have a resolution and the caller wants an exception then throw one.
  +  if (result = nil) and (AThrowOnFail) then
       begin
  -      //get the result as T
  -      if rego.Instance.QueryInterface(GetTypeData(pInfo).Guid,result) <> 0 then
  -        //should never happen?
  -        raise EIoCResolutionException.Create(Format('The Implementation registered for type %s does not actually implement %s' ,[pInfo.Name,pInfo.Name]));
  -    end
  +    case resolveResult of
  +      TResolveResult.Success : ;
  +      TResolveResult.InterfaceNotRegistered : errorMsg := Format('No implementation registered for type %s', [pInfo.Name]);
  +      TResolveResult.ImplNotRegistered : errorMsg := Format('The Implementation registered for type %s does not actually implement %s', [pInfo.Name, pInfo.Name]);
  +      TResolveResult.DeletegateFailedCreate : errorMsg := Format('The Implementation registered for type %s does not actually implement %s', [pInfo.Name, pInfo.Name]);
       else
  -    begin
  -      MonitorEnter(lcontainer);
  -      try
  -        if rego.ImplClass <> nil then
  -          rego.Instance := TClassActivator.CreateInstance(rego.ImplClass)
  -        else if rego.ActivatorDelegate <> nil then
  -        begin
  -          rego.Instance := rego.ActivatorDelegate();
  -          if rego.Instance = nil then
  -            raise EIoCResolutionException.Create(Format('The Activator Delegate registered for type %s did not instantiate an instance' ,[pInfo.Name]));
  -        end;
  -        //get the result as T
  -        if rego.Instance.QueryInterface( GetTypeData(pInfo).Guid,result) <> 0 then
  -        //should never happen?
  -          raise EIoCResolutionException.Create(Format('The Implementation registered for type %s does not actually implement %s' ,[pInfo.Name,pInfo.Name]));
  -
  -        lcontainer.AddOrSetValue(key,rego);
  -
  -      finally
  -        MonitorExit(lcontainer);
  -      end;
  +      //All other error types are treated as unknown until defined here.
  +      errorMsg := Format('An Unknown Error has occurred for the resolution of the interface %s %s. This is either because a new error type isn''t being handled, ' +
  +          'or it''s an bug.', [pInfo.Name, name]);
       end;
  -  end
  -  else
  -  begin
  -    MonitorEnter(lcontainer);
  -    try
  -      if rego.ImplClass <> nil then
  -      begin
  -        res := TClassActivator.CreateInstance(rego.ImplClass);
  -        if res.QueryInterface(GetTypeData(pInfo).Guid,result) <> 0 then
  -        //should never happen?
  -          raise EIoCResolutionException.Create(Format('The Implementation registered for type %s does not actually implement %s' ,[pInfo.Name,pInfo.Name]));
  -      end
  -      else if rego.ActivatorDelegate <> nil then
  -      begin
  -        activator := TActivatorDelegate<TInterface>(rego.ActivatorDelegate);
  -        res := activator();
  -        if res = nil then
  -          raise EIoCResolutionException.Create(Format('The Activator Delegate registered for type %s did not instantiate an instance' ,[pInfo.Name]));
  -        if res.QueryInterface(GetTypeData(pInfo).Guid,result) <> 0 then
  -        //should never happen?
  -          raise EIoCResolutionException.Create(Format('The Implementation registered for type %s does not actually implement %s' ,[pInfo.Name,pInfo.Name]));
  -      end;
  -
  -    finally
  -      MonitorExit(lcontainer);
  -    end;
  -  end;
  -
  +
  +    raise EIoCResolutionException.Create(errorMsg);
  +  end;
   end;
   
   end.
  
positive.code:   SysUtils;
  
  type
    TActivatorDelegate<TInterface: IInterface> = reference to function: TInterface;
  
  
  
negative.code:     procedure RegisterType<TInterface: IInterface>(const singleton : boolean;const delegate : TActivatorDelegate<TInterface>; const name : string);overload;
  
      //Resolution
      function Resolve<TInterface: IInterface>(const name: string = ''; const AThrowOnFail : boolean = false): TInterface;
  
      //Default Container - used internally by DUnitX
      class function DefaultContainer : TDUnitXIoC;
  