The following line cause problem. If I take this line out I don't get
80004005 error but the context menu item is grayed out; if I put this line
back the context menu item will be enabled for a while. By default the
commandBar Enabled is set to ture; Visible is set to false. I also checked VS
2003 it has similar seting for these two properties Enabled is set to ture;
Visible is set to false.
commandBar.Visible = true;
Here are the code snippt from OnConnection();
public void OnConnection(object theApplication,
Extensibility.ext_ConnectMode theConnectMode, object theAddInInstance, ref
System.Array theCustom)
{
myApplicationObject = (DTE2)theApplication;
myAddInInstance = (AddIn)theAddInInstance;
object[] contextGuides = new object[] { };
Commands commands = myApplicationObject.Commands;
Microsoft.VisualStudio.CommandBars._CommandBars commandBars =
(Microsoft.VisualStudio.CommandBars._CommandBars)(myApplicationObject.CommandBars);
CommandBar commandBar = (CommandBar)commandBars["Code Window"];
//commandBar.Visible = true; // This line cause the Add-in failed to load.
If don't add this line the context menu item will be grayed out.
try
{
if (myDebuggerEvents == null)
{
myDebuggerEvents = myApplicationObject.Events.DebuggerEvents;
}
myApplicationObject.Events.DebuggerEvents.OnEnterBreakMode += new
_dispDebuggerEvents_OnEnterBreakModeEventHandler(OnEnterBreakMode);
// Adds the command to the right click context menu.
Command command = commands.AddNamedCommand(myAddInInstance,
"VisualDebuggerNodeVS2005",
"VisualDebuggerVS2005",
"VisualDebuggerVS2005",
true,
1,
ref contextGuides,
(int)vsCommandStatus.vsCommandStatusSupported +
(int)vsCommandStatus.vsCommandStatusEnabled);
Microsoft.VisualStudio.CommandBars.CommandBarControl commandBarControl =
(Microsoft.VisualStudio.CommandBars.CommandBarControl)(command.AddControl(commandBar, 1));
}
catch (Exception)
{
}
}
Here are the message from Out Put window. The last line coused by this
commandBar.Visible = true.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.CommonIDE\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.CommonIDE.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio\2.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Shell\2.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Shell.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC\Microsoft.VisualStudio.Shell.Interop\7.1.40304.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Shell.Interop.dll', No symbols loaded.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC\Microsoft.VisualStudio.OLE.Interop\7.1.40304.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.OLE.Interop.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC\Microsoft.VisualStudio.Shell.Interop.8.0\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Shell.Interop.8.0.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC\Microsoft.VisualStudio.Designer.Interfaces\1.0.5000.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Designer.Interfaces.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing.Design\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.Design.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\System.Design\2.0.0.0__b03f5f7f11d50a3a\System.Design.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Build.Engine\2.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Engine.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Build.Framework\2.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Framework.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_32\CustomMarshalers\2.0.0.0__b03f5f7f11d50a3a\CustomMarshalers.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Design\2.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Design.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Shell.Design\2.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Shell.Design.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC\EnvDTE\8.0.0.0__b03f5f7f11d50a3a\EnvDTE.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Build.Tasks\2.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Tasks.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Build.Utilities\2.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Utilities.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
'devenv.exe' (Managed): Loaded
'K:\hjia_algorithms_miscellaneous_scr97\ALGORITHMS\Miscellaneous\VisualDebugger\Development\bin\Debug\BeckmanCoulter.Algorithms.VisualDebugger.dll',
Symbols loaded.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC\Extensibility\7.0.3300.0__b03f5f7f11d50a3a\Extensibility.dll', No symbols loaded.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC\Microsoft.VisualStudio.CommandBars\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.CommandBars.dll', No symbols loaded.
'devenv.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC\EnvDTE80\8.0.0.0__b03f5f7f11d50a3a\EnvDTE80.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just My
Code' is enabled.
A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in
BeckmanCoulter.Algorithms.VisualDebugger.dll
Dustin Campbell - 10 Aug 2006 17:32 GMT
It seems very unorthodox to me to set the visibility of a context menu within
the OnConnection handler of your add-in. What exactly are you trying to achieve?
Also, because the "CodeWindow" command bar is actually a context menu and
not a toolbar, you should probably use the CommandBar.ShowPopup() method.
Best Regards,
Dustin Campbell
Developer Express Inc.
Haiping - 10 Aug 2006 18:36 GMT
Hi Gary,
My Add-in is a visual debugger it works like this:
When debug the project hight an object , usually a histogram or an array,
and click the context menu item of my Add-in; the object will be shown on the
2D charts.
Carlos sugested me to change IDTCommandTarget.QueryStatus method not set
commandBar.Visible = true on hte OnConnect. It works fine now.
Thank you,
Haiping
Dustin Campbell - 10 Aug 2006 18:44 GMT
> Carlos sugested me to change IDTCommandTarget.QueryStatus method not
> set commandBar.Visible = true on hte OnConnect. It works fine now.
Ah ha. Yes, that would work as well.
Best Regards,
Dustin Campbell
Developer Express Inc.
Gary Chang[MSFT] - 11 Aug 2006 03:29 GMT
That's great, Haiping!
I am glad to know you have already found the resolution by the community
members' help. :)
Hav a nice day!
Best regards,
Gary Chang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Haiping - 11 Aug 2006 16:07 GMT
Hi Gary,
Yes. I am so glad that I found a good community. I should post my question
here earlier.
Thanks for your help.
We just create a installation package. It works nicely in our developer's
computer.
Haipoing