NEVERMIND :: I did not properly install the toolkit. I got it in my head, because I wasn't thinking properly, that all I needed was to place the menus DLL into the Addins folder alongside mine. That isn't how this toolkit works. If you spent time reading this post this morning, I'm sorry I wasted your time.
I am receiving an error in a client test environment when trying to deploy a GP Addin I built that leverages His Holiness Dave Musgrave's Menus for VS Tools library. On my development environment I have no issue. The error written to the Windows Event Log is below. Having my library in the Addins folder generates this error on GP launch and then GP closes down.
The description for Event ID 0 from source Microsoft Dexterity cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
An exception occurred while trying to load or initialize the addin located at D:\Apps\Microsoft Dynamics\Addins\Alcority.RSM.DynamicsGP.Addin.dll.
Exception Details:
System.TypeInitializationException: The type initializer for 'Microsoft.Dexterity.Applications.root' threw an exception. ---> System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: productId
at Microsoft.Dexterity.Bridge.DictionaryRoot.InitCookieInternal(DS_COOKIE* cookie, Int32 productId, Boolean isFormsDictionary)
at Microsoft.Dexterity.Bridge.DictionaryRoot.InitCookie()
at Microsoft.Dexterity.Bridge.DictionaryRoot.Init(String path, Int32 productId, Boolean isFormsDictionary, Boolean openForCodeGeneration)
at Microsoft.Dexterity.Bridge.DictionaryRoot..ctor(Int32 productId, Boolean isFormsDictionary)
at Microsoft.Dexterity.Applications.root..cctor()
--- End of inner exception stack trace ---
at Microsoft.Dexterity.Applications.MenusForVisualStudioToolsDictionary.EventRegisterFunction.get_WrappedScript()
at Microsoft.Dexterity.Bridge.FunctionBase.AddEventHandler(Delegate handler, AttachType attacyType)
at Microsoft.Dexterity.Applications.MenusForVisualStudioToolsDictionary.EventRegisterFunction.add_InvokeAfterOriginal(InvokeEventHandler value)
at Alcority.RSM.DynamicsGP.Addin.GPAddIn.Initialize() in C:\TFS\Dorilton Capital Mgmt\Alcority.RSM.DynamicsGP.Addin\Alcority.RSM.DynamicsGP.Addin\GpAddIn.cs:line 22
at Microsoft.Dexterity.Bridge.AddinManager.LoadAddin(String name, Type type, Boolean checkPlatformAttribute, Int32 currentDexPlatform)
the message resource is present but the message is not found in the string/message table
The project is meant to create a menu item in Project Accounting. Here is my code:
public void Initialize()
{
MenusForVisualStudioTools.Functions.EventRegister.InvokeAfterOriginal += new Microsoft.Dexterity.Applications.MenusForVisualStudioToolsDictionary.EventRegisterFunction.InvokeEventHandler(VSTMEventRegister);
MenusForVisualStudioTools.Functions.EventHandler.InvokeAfterOriginal += new Microsoft.Dexterity.Applications.MenusForVisualStudioToolsDictionary.EventHandlerFunction.InvokeEventHandler(VSTMEventHandler);
}
private void VSTMEventRegister(object sender, EventRegisterFunction.InvokeEventArgs e)
{
short parentTag = 0;
short belowTag = 0;
try
{
parentTag = MenusForVisualStudioTools.Functions.GetTagByName.Invoke(dynamicsProductID, "Command_System", "CL_Project_Utilities");
if (parentTag <= 0)
{
throw new Exception($"GetTagByName for Parent Tag failed. Error Code: {parentTag}");
}
belowTag = MenusForVisualStudioTools.Functions.GetTagByName.Invoke(projectProductID, "Command_PA", "PA_IV_Reconcile");
if (belowTag <= 0)
{
throw new Exception($"GetTagByName for Below Tag failed. Error Code: {belowTag}");
}
ProjectInvoicesWindowMenuTag = MenusForVisualStudioTools.Functions.Register.Invoke(
parentTag,
"Submit to Open Invoice",
"",
0,
0,
false,
false,
false,
belowTag,
true,
false);
if (ProjectInvoicesWindowMenuTag <= 0)
{
throw new Exception($"Register failed for Send to Open Invoice menu item. Error Code: {ProjectInvoicesWindowMenuTag}");
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message, appName);
if (ProjectInvoicesWindowMenuTag > 0)
{
short error = MenusForVisualStudioTools.Functions.Unregister.Invoke(parentTag, ProjectInvoicesWindowMenuTag);
if (error < 0)
{
System.Windows.Forms.MessageBox.Show($"Unregister failed. Error Code: {error}", appName);
}
}
}
}
private void VSTMEventHandler(object sender, EventHandlerFunction.InvokeEventArgs e)
{
short thisTag = e.inParam1;
if (thisTag == ProjectInvoicesWindowMenuTag)
{
OpenSendToOpenInvoice();
}
}
private void OpenSendToOpenInvoice()
{
SendProjectInvoices form = new SendProjectInvoices();
form.Location = new System.Drawing.Point(200,200);
form.Activate();
form.Show();
}