private BindingSource CreateNewBindingSource(object dataSource, string dataMember) { if ((this.hostSvc == null) || (this.dspSvc == null)) { return null; } BindingSource component = new BindingSource(); try { component.DataSource = dataSource; component.DataMember = dataMember; } catch (Exception exception) { IUIService uiService = this.serviceProvider.GetService(typeof(IUIService)) as IUIService; DataGridViewDesigner.ShowErrorDialog(uiService, exception, this); return null; } string bindingSourceNamePrefix = this.GetBindingSourceNamePrefix(dataSource, dataMember); if (this.serviceProvider != null) { bindingSourceNamePrefix = ToolStripDesigner.NameFromText(bindingSourceNamePrefix, component.GetType(), this.serviceProvider); } else { bindingSourceNamePrefix = bindingSourceNamePrefix + component.GetType().Name; } string uniqueSiteName = DesignerUtils.GetUniqueSiteName(this.hostSvc, bindingSourceNamePrefix); DesignerTransaction transaction = this.hostSvc.CreateTransaction(System.Design.SR.GetString("DesignerBatchCreateTool", new object[] { uniqueSiteName })); try { try { this.hostSvc.Container.Add(component, uniqueSiteName); } catch (InvalidOperationException exception2) { if (transaction != null) { transaction.Cancel(); } IUIService service = this.serviceProvider.GetService(typeof(IUIService)) as IUIService; DataGridViewDesigner.ShowErrorDialog(service, exception2, this); return null; } catch (CheckoutException exception3) { if (transaction != null) { transaction.Cancel(); } IUIService service3 = this.serviceProvider.GetService(typeof(IUIService)) as IUIService; DataGridViewDesigner.ShowErrorDialog(service3, exception3, this); return null; } this.dspSvc.NotifyDataSourceComponentAdded(component); if (transaction != null) { transaction.Commit(); transaction = null; } } finally { if (transaction != null) { transaction.Cancel(); } } return component; }