Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Argument Out of Range Exception : Menus for VS Tools

Posted on by 1,582

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();
}

Categories:
  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,926 Most Valuable Professional on at
    RE: Argument Out of Range Exception : Menus for VS Tools

    Hi Chad

    I don't think I am a religious icon yet.

    I am assuming you are actually using the Visual Studio Integration Toolkit (VSIT) as Menus For Visual Studio Tools was discontinued when I left Microsoft. 

    I did not change many of file names or objects to ensure compatibility with old code.

    Glad you have it sorted.

    It needs installation as there are Dexterity components needed which actually do the menus, area pages and helper functions. These are just exposed to VSTools via the DLL files.

    Regards

    David

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans