public object Build(IBuilderContext context, GetNextBuilderDelegate next) { object target = next()(context, next); var proxyServer = context.CreateInstance(proxyServerType, null, new IBuilderValue[] { new TypedValue(typeof(object), null, target) }) as ProxyServer; if (isTransparentProxy) { lock (TransparentProxyAttribute.lockProxyServerField) { TransparentProxyAttribute.proxyServer = proxyServer; try { //error //return injector.CreateInstance(proxyType, null, // new IInjectValue[] { //new InjectValue(typeof(InjectProxy), null, proxy) // }); target = Activator.CreateInstance(proxyType); } finally { TransparentProxyAttribute.proxyServer = null; } } } else { List <IBuilderValue> values = new List <IBuilderValue>(context.Values); values.Add(new TypedValue(typeof(ProxyServer), null, proxyServer)); values.Add(new TypedValue(proxyServerType, null, proxyServer)); values.Add(new TypedValue(context.TargetType, null, target)); target = context.CreateInstance(proxyType, null, values.ToArray()); } return(target); }