Browse Source

Fixed crash when trying to view components in assembly Microsoft.VisualStudio.CommonIDE. (forum-5369)

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1178 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
23d5b75f68
  1. 99
      src/AddIns/DisplayBindings/FormsDesigner/Project/Resources/AddSidebarComponentsDialog.xfrm
  2. 76
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/AddComponentsDialog.cs
  3. 2
      src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

99
src/AddIns/DisplayBindings/FormsDesigner/Project/Resources/AddSidebarComponentsDialog.xfrm

@ -1,64 +1,61 @@
<Components version="1.0"> <Components version="1.0">
<System.Windows.Forms.Form> <System.Windows.Forms.Form>
<Name value="AddComponentsDialog" /> <Name value="AddComponentsDialog" />
<ShowInTaskbar value="False" />
<FormBorderStyle value="FixedDialog" />
<StartPosition value="CenterScreen" />
<ClientSize value="{Width=522, Height=394}" />
<MinimizeBox value="False" /> <MinimizeBox value="False" />
<DockPadding value="" /> <StartPosition value="CenterScreen" />
<ShowInTaskbar value="False" />
<Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.DialogName}" /> <Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.DialogName}" />
<AcceptButton value="okButton [System.Windows.Forms.Button], Text: ${res:Global.OKButtonText}" /> <AcceptButton value="okButton [System.Windows.Forms.Button], Text: ${res:Global.OKButtonText}" />
<CancelButton value="cancelButton [System.Windows.Forms.Button], Text: ${res:Global.CancelButtonText}" /> <CancelButton value="cancelButton [System.Windows.Forms.Button], Text: ${res:Global.CancelButtonText}" />
<MaximizeBox value="False" /> <MaximizeBox value="False" />
<ClientSize value="{Width=685, Height=394}" />
<Controls> <Controls>
<System.Windows.Forms.Button> <System.Windows.Forms.Button>
<Name value="cancelButton" /> <Name value="cancelButton" />
<Location value="{X=437,Y=363}" /> <DialogResult value="Cancel" />
<ClientSize value="{Width=75, Height=23}" /> <Location value="{X=600,Y=363}" />
<Text value="${res:Global.CancelButtonText}" /> <Text value="${res:Global.CancelButtonText}" />
<Anchor value="Bottom, Right" /> <Anchor value="Bottom, Right" />
<Size value="{Width=75, Height=23}" />
<TabIndex value="2" /> <TabIndex value="2" />
<DialogResult value="Cancel" />
</System.Windows.Forms.Button> </System.Windows.Forms.Button>
<System.Windows.Forms.Button> <System.Windows.Forms.Button>
<Name value="okButton" /> <Name value="okButton" />
<Location value="{X=357,Y=363}" /> <DialogResult value="OK" />
<ClientSize value="{Width=75, Height=23}" /> <Location value="{X=520,Y=363}" />
<Text value="${res:Global.OKButtonText}" /> <Text value="${res:Global.OKButtonText}" />
<Anchor value="Bottom, Right" /> <Anchor value="Bottom, Right" />
<Size value="{Width=75, Height=23}" />
<TabIndex value="1" /> <TabIndex value="1" />
<DialogResult value="OK" />
</System.Windows.Forms.Button> </System.Windows.Forms.Button>
<System.Windows.Forms.Panel> <System.Windows.Forms.Panel>
<Name value="panel" /> <Name value="panel" />
<Location value="{X=8,Y=8}" /> <Location value="{X=8,Y=8}" />
<ClientSize value="{Width=504, Height=347}" />
<DockPadding value="" />
<Anchor value="Top, Bottom, Left, Right" />
<TabIndex value="0" /> <TabIndex value="0" />
<Anchor value="Top, Bottom, Left, Right" />
<Size value="{Width=667, Height=347}" />
<Controls> <Controls>
<System.Windows.Forms.ListView> <System.Windows.Forms.ListView>
<Name value="componentListView" /> <Name value="componentListView" />
<GridLines value="True" /> <CheckBoxes value="True" />
<Dock value="Fill" /> <Size value="{Width=403, Height=331}" />
<TabIndex value="3" /> <TabIndex value="3" />
<View value="Details" />
<FullRowSelect value="True" /> <FullRowSelect value="True" />
<Location value="{X=203,Y=16}" /> <GridLines value="True" />
<ClientSize value="{Width=297, Height=327}" /> <View value="Details" />
<CheckBoxes value="True" />
<HideSelection value="False" /> <HideSelection value="False" />
<Dock value="Fill" />
<Location value="{X=264,Y=16}" />
<Columns> <Columns>
<System.Windows.Forms.ColumnHeader> <System.Windows.Forms.ColumnHeader>
<Width value="82" /> <Width value="128" />
<Name value="componentColumnHeader1" />
<Text value="${res:Global.Name}" /> <Text value="${res:Global.Name}" />
<Name value="componentColumnHeader1" />
</System.Windows.Forms.ColumnHeader> </System.Windows.Forms.ColumnHeader>
<System.Windows.Forms.ColumnHeader> <System.Windows.Forms.ColumnHeader>
<Width value="88" /> <Width value="88" />
<Name value="componentColumnHeader2" />
<Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.Components.Namespace}" /> <Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.Components.Namespace}" />
<Name value="componentColumnHeader2" />
</System.Windows.Forms.ColumnHeader> </System.Windows.Forms.ColumnHeader>
<System.Windows.Forms.ColumnHeader> <System.Windows.Forms.ColumnHeader>
<Name value="componentColumnHeader3" /> <Name value="componentColumnHeader3" />
@ -72,53 +69,50 @@
</System.Windows.Forms.ListView> </System.Windows.Forms.ListView>
<System.Windows.Forms.Label> <System.Windows.Forms.Label>
<Name value="label2" /> <Name value="label2" />
<Location value="{X=264,Y=0}" />
<Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.ComponentsToAddLabel}" /> <Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.ComponentsToAddLabel}" />
<TabIndex value="2" /> <Size value="{Width=403, Height=16}" />
<ClientSize value="{Width=301, Height=16}" />
<Location value="{X=203,Y=0}" />
<Dock value="Top" /> <Dock value="Top" />
<TabIndex value="2" />
</System.Windows.Forms.Label> </System.Windows.Forms.Label>
<System.Windows.Forms.Splitter> <System.Windows.Forms.Splitter>
<Name value="splitter" /> <Name value="splitter" />
<Location value="{X=261,Y=0}" />
<TabIndex value="1" /> <TabIndex value="1" />
<ClientSize value="{Width=3, Height=347}" /> <Size value="{Width=3, Height=347}" />
<Location value="{X=200,Y=0}" />
</System.Windows.Forms.Splitter> </System.Windows.Forms.Splitter>
<System.Windows.Forms.Panel> <System.Windows.Forms.Panel>
<Name value="panel2" /> <Name value="panel2" />
<Location value="{X=0,Y=0}" /> <Location value="{X=0,Y=0}" />
<ClientSize value="{Width=200, Height=347}" />
<DockPadding value="" />
<TabIndex value="0" /> <TabIndex value="0" />
<Size value="{Width=261, Height=347}" />
<Dock value="Left" /> <Dock value="Left" />
<Controls> <Controls>
<System.Windows.Forms.TabControl> <System.Windows.Forms.TabControl>
<Name value="tabControl" /> <Name value="tabControl" />
<TabIndex value="1" />
<Dock value="Fill" />
<ClientSize value="{Width=200, Height=347}" />
<Location value="{X=0,Y=0}" /> <Location value="{X=0,Y=0}" />
<Dock value="Fill" />
<TabIndex value="1" />
<Size value="{Width=261, Height=347}" />
<TabPages> <TabPages>
<System.Windows.Forms.TabPage> <System.Windows.Forms.TabPage>
<Name value="gacTabPage" /> <Name value="gacTabPage" />
<DockPadding value="" />
<Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.GACTabPage}" /> <Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.GACTabPage}" />
<ClientSize value="{Width=192, Height=321}" /> <Size value="{Width=253, Height=321}" />
<Location value="{X=4,Y=22}" />
<Controls> <Controls>
<System.Windows.Forms.ListView> <System.Windows.Forms.ListView>
<Name value="gacListView" /> <Name value="gacListView" />
<Dock value="Fill" /> <Size value="{Width=253, Height=321}" />
<MultiSelect value="False" />
<TabIndex value="0" /> <TabIndex value="0" />
<View value="Details" />
<FullRowSelect value="True" /> <FullRowSelect value="True" />
<Location value="{X=0,Y=0}" /> <MultiSelect value="False" />
<ClientSize value="{Width=188, Height=317}" /> <View value="Details" />
<HideSelection value="False" /> <HideSelection value="False" />
<Dock value="Fill" />
<Location value="{X=0,Y=0}" />
<Columns> <Columns>
<System.Windows.Forms.ColumnHeader> <System.Windows.Forms.ColumnHeader>
<Width value="100" /> <Width value="147" />
<Name value="columnHeader5" /> <Name value="columnHeader5" />
<Text value="${res:Global.Name}" /> <Text value="${res:Global.Name}" />
</System.Windows.Forms.ColumnHeader> </System.Windows.Forms.ColumnHeader>
@ -133,41 +127,38 @@
</System.Windows.Forms.TabPage> </System.Windows.Forms.TabPage>
<System.Windows.Forms.TabPage> <System.Windows.Forms.TabPage>
<Name value="customTabPage" /> <Name value="customTabPage" />
<DockPadding value="" />
<Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.CustomTabPage}" /> <Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponents.CustomTabPage}" />
<ClientSize value="{Width=192, Height=326}" /> <Size value="{Width=253, Height=321}" />
<Location value="{X=4,Y=22}" />
<Controls> <Controls>
<System.Windows.Forms.Button> <System.Windows.Forms.Button>
<Name value="browseButton" /> <Name value="browseButton" />
<Location value="{X=157,Y=27}" /> <Location value="{X=218,Y=27}" />
<ClientSize value="{Width=32, Height=20}" />
<Text value="..." /> <Text value="..." />
<Anchor value="Top, Right" /> <Anchor value="Top, Right" />
<Size value="{Width=32, Height=20}" />
<TabIndex value="2" /> <TabIndex value="2" />
</System.Windows.Forms.Button> </System.Windows.Forms.Button>
<System.Windows.Forms.TextBox> <System.Windows.Forms.TextBox>
<Name value="fileNameTextBox" /> <Name value="fileNameTextBox" />
<Anchor value="Top, Left, Right" />
<TabIndex value="1" /> <TabIndex value="1" />
<Size value="{Width=205, Height=21}" />
<Location value="{X=8,Y=28}" /> <Location value="{X=8,Y=28}" />
<ClientSize value="{Width=140, Height=17}" /> <Anchor value="Top, Left, Right" />
<Text value="" />
</System.Windows.Forms.TextBox> </System.Windows.Forms.TextBox>
<System.Windows.Forms.Label> <System.Windows.Forms.Label>
<Name value="label3" /> <Name value="label3" />
<Location value="{X=8,Y=8}" />
<Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponentsFileNameLabel}" /> <Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.AddSidebarComponentsFileNameLabel}" />
<TextAlign value="BottomLeft" />
<Anchor value="Top, Left, Right" /> <Anchor value="Top, Left, Right" />
<TextAlign value="BottomLeft" />
<Size value="{Width=237, Height=16}" />
<TabIndex value="0" /> <TabIndex value="0" />
<ClientSize value="{Width=176, Height=16}" />
<Location value="{X=8,Y=8}" />
</System.Windows.Forms.Label> </System.Windows.Forms.Label>
<System.Windows.Forms.Button> <System.Windows.Forms.Button>
<Name value="loadButton" /> <Name value="loadButton" />
<Location value="{X=8,Y=60}" /> <Location value="{X=8,Y=60}" />
<ClientSize value="{Width=150, Height=23}" />
<Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.ShowComponentsButton}" /> <Text value="${res:ICSharpCode.SharpDevelop.FormDesigner.Gui.ShowComponentsButton}" />
<Size value="{Width=150, Height=23}" />
<TabIndex value="3" /> <TabIndex value="3" />
</System.Windows.Forms.Button> </System.Windows.Forms.Button>
</Controls> </Controls>

76
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Gui/AddComponentsDialog.cs

@ -92,52 +92,48 @@ namespace ICSharpCode.FormsDesigner.Gui
} catch {} } catch {}
} }
try { try {
Module[] ms = assembly.GetModules(false);
((ListView)ControlDictionary["componentListView"]).SmallImageList = il; ((ListView)ControlDictionary["componentListView"]).SmallImageList = il;
foreach (Module m in ms) { foreach (Type t in assembly.GetExportedTypes()) {
Type[] ts = m.GetTypes(); if (!t.IsAbstract) {
foreach (Type t in ts) { if (t.IsDefined(typeof(ToolboxItemFilterAttribute), true) || t.IsDefined(typeof(ToolboxItemAttribute), true) || typeof(System.ComponentModel.IComponent).IsAssignableFrom(t)) {
if (t.IsPublic && !t.IsAbstract) { object[] attributes = t.GetCustomAttributes(false);
if (t.IsDefined(typeof(ToolboxItemFilterAttribute), true) || t.IsDefined(typeof(ToolboxItemAttribute), true) || typeof(System.ComponentModel.IComponent).IsAssignableFrom(t)) { object[] filterAttrs = t.GetCustomAttributes(typeof(DesignTimeVisibleAttribute), true);
object[] attributes = t.GetCustomAttributes(false); foreach (DesignTimeVisibleAttribute visibleAttr in filterAttrs) {
object[] filterAttrs = t.GetCustomAttributes(typeof(DesignTimeVisibleAttribute), true); if (!visibleAttr.Visible) {
foreach (DesignTimeVisibleAttribute visibleAttr in filterAttrs) { goto skip;
if (!visibleAttr.Visible) {
goto skip;
}
} }
}
if (images[t.FullName + ".bmp"] == null) {
if (t.IsDefined(typeof(ToolboxBitmapAttribute), false)) { if (images[t.FullName + ".bmp"] == null) {
foreach (object attr in attributes) { if (t.IsDefined(typeof(ToolboxBitmapAttribute), false)) {
if (attr is ToolboxBitmapAttribute) { foreach (object attr in attributes) {
ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr; if (attr is ToolboxBitmapAttribute) {
images[t.FullName + ".bmp"] = il.Images.Count; ToolboxBitmapAttribute toolboxBitmapAttribute = (ToolboxBitmapAttribute)attr;
Bitmap b = new Bitmap(toolboxBitmapAttribute.GetImage(t)); images[t.FullName + ".bmp"] = il.Images.Count;
b.MakeTransparent(); Bitmap b = new Bitmap(toolboxBitmapAttribute.GetImage(t));
il.Images.Add(b); b.MakeTransparent();
break; il.Images.Add(b);
} break;
} }
} }
} }
ListViewItem newItem = new ListViewItem(t.Name);
newItem.SubItems.Add(t.Namespace);
newItem.SubItems.Add(assembly.ToString());
newItem.SubItems.Add(assembly.Location);
newItem.SubItems.Add(t.Namespace);
if (images[t.FullName + ".bmp"] != null) {
newItem.ImageIndex = (int)images[t.FullName + ".bmp"];
}
newItem.Checked = true;
ToolComponent toolComponent = new ToolComponent(t.FullName, new ComponentAssembly(assembly.FullName, loadPath));
toolComponent.IsEnabled = true;
newItem.Tag = toolComponent;
((ListView)ControlDictionary["componentListView"]).Items.Add(newItem);
ToolboxItem item = new ToolboxItem(t);
skip:;
} }
ListViewItem newItem = new ListViewItem(t.Name);
newItem.SubItems.Add(t.Namespace);
newItem.SubItems.Add(assembly.ToString());
newItem.SubItems.Add(assembly.Location);
newItem.SubItems.Add(t.Namespace);
if (images[t.FullName + ".bmp"] != null) {
newItem.ImageIndex = (int)images[t.FullName + ".bmp"];
}
newItem.Checked = true;
ToolComponent toolComponent = new ToolComponent(t.FullName, new ComponentAssembly(assembly.FullName, loadPath));
toolComponent.IsEnabled = true;
newItem.Tag = toolComponent;
((ListView)ControlDictionary["componentListView"]).Items.Add(newItem);
ToolboxItem item = new ToolboxItem(t);
skip:;
} }
} }
} }

2
src/Main/Base/Project/Src/Services/Debugger/DebuggerService.cs

@ -55,7 +55,7 @@ namespace ICSharpCode.Core
project = ProjectService.OpenSolution.StartupProject; project = ProjectService.OpenSolution.StartupProject;
} }
foreach (DebuggerDescriptor d in debuggers) { foreach (DebuggerDescriptor d in debuggers) {
if (d.Debugger.CanDebug(project)) { if (d.Debugger != null && d.Debugger.CanDebug(project)) {
return d.Debugger; return d.Debugger;
} }
} }

Loading…
Cancel
Save