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; } }