Visual Studio AddIn problem - adding a sub-menu to the Edit menu
-
Hi all, I wonder if anyone can help with a problem I am having with an AddIn I am writing for Visual Studio.NET I am try to add a submenu to the Edit menu with two items in it. I would assume this is done by creating a CommandBar of type vsCommandBarTypeMenu and specifying the Edit menu as the parent, such as the code below:
CommandBar EditMenu = (CommandBar)applicationObject.CommandBars["Edit"]; ....... ......... CommandBar MySubMenu = (CommandBar)applicationObject.Commands.AddCommandBar("My Sub Menu", vsCommandBarType.vsCommandBarTypeMenu, EditMenu, 0);
However, when I try to add the CommandBar, a COMException is thrown with the message "Class not registered. Looking for object with CLID {.........}". What am I doing wrong here? Regards, Chris -
Hi all, I wonder if anyone can help with a problem I am having with an AddIn I am writing for Visual Studio.NET I am try to add a submenu to the Edit menu with two items in it. I would assume this is done by creating a CommandBar of type vsCommandBarTypeMenu and specifying the Edit menu as the parent, such as the code below:
CommandBar EditMenu = (CommandBar)applicationObject.CommandBars["Edit"]; ....... ......... CommandBar MySubMenu = (CommandBar)applicationObject.Commands.AddCommandBar("My Sub Menu", vsCommandBarType.vsCommandBarTypeMenu, EditMenu, 0);
However, when I try to add the CommandBar, a COMException is thrown with the message "Class not registered. Looking for object with CLID {.........}". What am I doing wrong here? Regards, ChrisPurely speculation but I think you need to register your .NET object as a COM object using the wrappers so that Visual Studio can gain access to it Jared jparsons@jparsons.org www.prism.gatech.edu/~gte477n
-
Hi all, I wonder if anyone can help with a problem I am having with an AddIn I am writing for Visual Studio.NET I am try to add a submenu to the Edit menu with two items in it. I would assume this is done by creating a CommandBar of type vsCommandBarTypeMenu and specifying the Edit menu as the parent, such as the code below:
CommandBar EditMenu = (CommandBar)applicationObject.CommandBars["Edit"]; ....... ......... CommandBar MySubMenu = (CommandBar)applicationObject.Commands.AddCommandBar("My Sub Menu", vsCommandBarType.vsCommandBarTypeMenu, EditMenu, 0);
However, when I try to add the CommandBar, a COMException is thrown with the message "Class not registered. Looking for object with CLID {.........}". What am I doing wrong here? Regards, ChrisChris Morrison wrote: However, when I try to add the CommandBar, a COMException is thrown with the message "Class not registered. Looking for object with CLID {.........}". It sounds as if the CLSID is not being found in the registry, thus it is not able to load the COM Server because it doesn't know it's location. Are you using a third-party component that hasn't been registered? If so, pull up a command prompt, navigate to the directory of your COM .dll and type the following:
regsvr32 "[YourComponent.dll]"
Not entirely sure this is your problem, however here are a few links that might be of some help: COMException Class[^] HRESULTs and Exceptions[^] Nick Parker - DeveloperNotes.com
VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done.
-Don Box -
Chris Morrison wrote: However, when I try to add the CommandBar, a COMException is thrown with the message "Class not registered. Looking for object with CLID {.........}". It sounds as if the CLSID is not being found in the registry, thus it is not able to load the COM Server because it doesn't know it's location. Are you using a third-party component that hasn't been registered? If so, pull up a command prompt, navigate to the directory of your COM .dll and type the following:
regsvr32 "[YourComponent.dll]"
Not entirely sure this is your problem, however here are a few links that might be of some help: COMException Class[^] HRESULTs and Exceptions[^] Nick Parker - DeveloperNotes.com
VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done.
-Don BoxNick Parker wrote: Chris Morrison wrote: However, when I try to add the CommandBar, a COMException is thrown with the message "Class not registered. Looking for object with CLID {.........}". It sounds as if the CLSID is not being found in the regisry, thus it is not able to load the COM Server because it doesn't know it's location. Are you using a third-party component that hasn't been registered? If so, pull up a command prompt, navigate to the directory of your COM .dll and type the following: regsvr32 "[YourComponent.dll]" That did not work and caused an error. I would have thought that any registrations that were required would be performed when I build and debug the Add-In. Also I have added a floating toolbar to the IDE with no problems, and I can add new items directly to the Edit menu with out error, so I can't see why I am having problems adding a sub menu to it. This is very strange.:confused::mad: Chris
-
Nick Parker wrote: Chris Morrison wrote: However, when I try to add the CommandBar, a COMException is thrown with the message "Class not registered. Looking for object with CLID {.........}". It sounds as if the CLSID is not being found in the regisry, thus it is not able to load the COM Server because it doesn't know it's location. Are you using a third-party component that hasn't been registered? If so, pull up a command prompt, navigate to the directory of your COM .dll and type the following: regsvr32 "[YourComponent.dll]" That did not work and caused an error. I would have thought that any registrations that were required would be performed when I build and debug the Add-In. Also I have added a floating toolbar to the IDE with no problems, and I can add new items directly to the Edit menu with out error, so I can't see why I am having problems adding a sub menu to it. This is very strange.:confused::mad: Chris
Try running regasm.exe on your .NET assembly. It is equivalent to regsvr32.exe but is for managed assemblies. Since such assemblies do not export
DllRegisterServer
orDllUnregisterServer
, regsvr32.exe is useless.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
-
Try running regasm.exe on your .NET assembly. It is equivalent to regsvr32.exe but is for managed assemblies. Since such assemblies do not export
DllRegisterServer
orDllUnregisterServer
, regsvr32.exe is useless.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----
Heath Stewart wrote: Since such assemblies do not export DllRegisterServer or DllUnregisterServer, regsvr32.exe is useless. I would have suggested that but since it was throwing a
COMException
I figured it was due to a problem on the other side of the fence. :) Oh well, it's the weekend after all. :) -Nick Parker VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done.
-Don Box -
Heath Stewart wrote: Since such assemblies do not export DllRegisterServer or DllUnregisterServer, regsvr32.exe is useless. I would have suggested that but since it was throwing a
COMException
I figured it was due to a problem on the other side of the fence. :) Oh well, it's the weekend after all. :) -Nick Parker VB gets under people's skin because one can be ignorant of computer architecture and ASM and still get a lot done.
-Don BoxVS.NET uses the DTE components via COM (even if written in managed code), so if it can't find the registered class (either because it wasn't registered correctly or because he moved the DLL after registering it) it would throw such a
COMException
.-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----