Re: VS crash during addin uninstalling
From: Carlos J. Quintero [MVP] (carlosq_at_NOSPAMsogecable.com)
Date: 06/23/04
- Previous message: Ales Riha: "How to get IDesignerHost for Web Form from add-in?"
- In reply to: Szymon Madejczyk: "VS crash during addin uninstalling"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Jun 2004 09:56:49 +0200
Some ideas:
1) Try to get the exception message. It seems that you are catching and
silencing the exceptions. Use MessageBoxes.
2) If that fails, try to trim your code until you find the culprit. FOr
example, you are doing 3 things: removing controls from command bar,
removing commandbar and removing commands. Surely only one of the 3 is
causing the problem... so try to isolate which one executing only one in
each test.
-- Carlos J. Quintero (Visual Developer - .NET MVP) FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET addins: http://groups.yahoo.com/group/vsnetaddin/ (free join) "Szymon Madejczyk" <smad@parasoft.com.pl> escribió en el mensaje news:cb9j7g$5uf$1@nemesis.news.tpi.pl... > Hello, > > I encountered strange problem. When following code is compiled in Debug it works > ok. However when I compile it in Release. During uninstal VS .net 2003 display > crash warning. What is more no exception is thrown. > BTW addins are removed properly. > > Someone has idea what I do wrong. > > thanks > Szymek > > using System; > using System.Collections; > using System.Diagnostics; > using System.IO; > > using EnvDTE; > using Microsoft.Office.Core; > > namespace AddinRemover > { > public sealed class Remover > { > private Remover() > { > } // private Cleaner() > > private const string VS_71_PROG_ID = "VisualStudio.DTE.7.1"; > private const string VS_70_PROG_ID = "VisualStudio.DTE.7"; > private const string ADDIN_NAME_COMMON_PART = "MyAddIn"; > private const string CMD_BAR_NAME = "My"; > private const string ADDIN_NAME = "My"; > > private static void RemoveAddin(string progId) > { > Type vsType = Type.GetTypeFromProgID(progId); > if (vsType != null) > { > object dteObj = Activator.CreateInstance(vsType); > if (dteObj != null) > { > DTE dte = (DTE)dteObj; > try > { > RemoveCommands(dte); > } > catch(Exception e) > { > Exception exp = e; > } > //dte.Quit(); > dte = null; > GC.Collect(); > } > } > } > > private static void RemoveCommands(DTE dte) > { > Commands cmds = dte.Commands; > _CommandBars commandBars = dte.CommandBars; > > try > { > CommandBar toolCommandBar = (CommandBar)commandBars["Tools"]; > CommandBarControls ctrls = toolCommandBar.Controls; > IEnumerator en = ctrls.GetEnumerator(); > while(en.MoveNext()) > { > CommandBarControl ctrl = (CommandBarControl)en.Current; > if (CMD_BAR_NAME == ctrl.Caption) > { > ctrl.Delete(false); > } > } > } > catch(Exception /*e*/) > { > //TODO: logging > } > > foreach(Command cmdDel in cmds) > { > if (cmdDel != null && cmdDel.Name != null && > cmdDel.Name.IndexOf(ADDIN_NAME_COMMON_PART) >= 0) > { > try > { > cmdDel.Delete ( ) ; > } > catch(Exception /*e*/) > { > //TODO: logging > } > } > } > > try > { > CommandBar cmdBar = (CommandBar)commandBars[CMD_BAR_NAME]; > cmds.RemoveCommandBar(cmdBar); > } > catch(Exception /*e*/) > { > //TODO: logging > } > } > > public static void Main(string[] args) > { > try > { > Remover.RemoveAddin(VS_70_PROG_ID); > } > catch(Exception /*e*/) > { > //TODO: logging > } > > try > { > Remover.RemoveAddin(VS_71_PROG_ID); > } > catch(Exception /*e*/) > { > //TODO: logging > } > } > } > }
- Previous message: Ales Riha: "How to get IDesignerHost for Web Form from add-in?"
- In reply to: Szymon Madejczyk: "VS crash during addin uninstalling"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|