
Signature
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
The add-in loads and functions fine if I manually add it via
"Tools\Customize\Rearrange Commands", so it does appear to function at
least.
Here's the registry settings under Addins.
HKLM\SOFTWARE\Microsoft\VisualStudio\8.0\Addins\AddIn_NET.Connect\CommandPreload
= 1
HKLM\SOFTWARE\Microsoft\VisualStudio\8.0\Addins\AddIn_NET.Connect\LoadBehavior
= 1
HKLM\SOFTWARE\Microsoft\VisualStudio\8.0\Addins\AddIn_NET.Connect\FriendlyName
= "Formal Add In Name"
HKLM\SOFTWARE\Microsoft\VisualStudio\8.0\Addins\AddIn_NET.Connect\SatelliteDLLName=AddIn_NETSatellite_2005.dll
HKLM\SOFTWARE\Microsoft\VisualStudio\8.0\Addins\AddIn_NET.Connect\SatelliteDLLPath=C:\Program
Files\Microsoft Visual Studio 8\Common7\IDE
Under PreloadAddinState:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\PreloadAddinState\AddIn_NET.Connect=1
Perhaps, the code could stand improvement - although it functioned before.
We're using DTE.CommandBars.AddControl(), but the code doesn't make it that
far. It does not get past "if(ConnectMode ==
AddInDesignerObjects::ext_cm_UISetup)" below. If I comment that out,
DTE.Commands.AddNamedCommand() fails - probably because it is not at the
proper ConnectMode. I can debug the 2002/2003 version to see what it used
to do if needed.
Here's OnConnection():
#define IfFailGoCheck(x, p) { hr=(x); if (FAILED(hr)) goto Error; if(!p) {hr
= E_FAIL; goto Error; } }
STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
AddInDesignerObjects::ext_ConnectMode ConnectMode, IDispatch *pAddInInst,
SAFEARRAY ** /*custom*/ )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
HRESULT hr = S_OK;
m_pApplication = pApplication;
pApplication->QueryInterface(__uuidof(EnvDTE::_DTE), (LPVOID*)&m_pDTE);
pAddInInst->QueryInterface(__uuidof(EnvDTE::AddIn),
(LPVOID*)&m_pAddInInstance);
if(ConnectMode == AddInDesignerObjects::ext_cm_UISetup) // Does not get
this far unless commented out.
{
hr = S_OK;
CComPtr<EnvDTE::Commands> pCommands;
CComPtr<Office::_CommandBars> pCommandBars;
CComPtr<Office::CommandBarControl> pCommandBarControl;
CComPtr<EnvDTE::Command> pCreatedCommand;
CComPtr<Office::CommandBar> pMenuBarCommandBar;
IfFailGoCheck(m_pDTE->get_Commands(&pCommands), pCommands);
// Fails with invalid argument.
if(SUCCEEDED(hr = pCommands->AddNamedCommand(m_pAddInInstance,
CComBSTR("AddIn"),
CComBSTR("Formal Add In Name"), CComBSTR("Formal Add In Name"),
VARIANT_FALSE, 1, NULL,
EnvDTE::vsCommandStatusSupported+EnvDTE::vsCommandStatusEnabled,
&pCreatedCommand)) &&
(pCreatedCommand))
{
try
{
// This code had to be changed slightly to compile in
VS.Net 2005:
if ((hr =
m_pDTE->get_CommandBars((IDispatch**)&pCommandBars)) != S_OK)
throw hr;
if ((hr = pCommandBars->get_Item(CComVariant(L"Tools"),
&pMenuBarCommandBar)) != S_OK)
throw hr;
if ((hr = pCreatedCommand->AddControl(pMenuBarCommandBar,
1, (IDispatch**)&pCommandBarControl)) != S_OK)
throw hr;
}
catch (int i)
{
return i;
}
catch (_com_error err)
{
::MessageBox(NULL, err.ErrorMessage(), "ERROR", IDOK);
}
}
return S_OK;
}
Error:
return hr;
}
Thanks, Jackie
> Are you using a permanent toolbar (DTE.Commands.AddCommandBar) or a
> temporary toolbar (DTE.CommandBars.Add) ?
[quoted text clipped - 21 lines]
>>
>> Thanks. Jackie
I tried DTE.Commands.AddCommandBar, and it works fine in VS.Net 2005.
Thanks.
> Are you using a permanent toolbar (DTE.Commands.AddCommandBar) or a
> temporary toolbar (DTE.CommandBars.Add) ?
[quoted text clipped - 21 lines]
>>
>> Thanks. Jackie