/// <summary> /// Returns a service object given the specified <see cref="T:System.ServiceModel.InstanceContext" /> object. /// </summary> /// <param name="instanceContext">The current <see cref="T:System.ServiceModel.InstanceContext" /> object.</param> /// <returns> /// A user-defined service object. /// </returns> public object GetInstance(InstanceContext instanceContext) { var scope = instanceContext.BeginScope(); try { return(scope.Resolver.Resolve(_serviceType)); } catch { scope.Dispose(); throw; } }
public object GetInstance(InstanceContext instanceContext) { var scope = instanceContext.BeginScope(); try { return(this.container.GetInstance(this.serviceType)); } catch { // We need to dispose the scope here, because WCF will never call ReleaseInstance if // this method throws an exception (since it has no instance to pass to ReleaseInstance). scope.Dispose(); throw; } }