Error "System.ArgumentNullException: Key cannot be null" when i add twice same project item

Hi,

I have an error in my package.


I add a solution I add an project : ok
I add an item project (ex BizComponents): ok
When i add the same item project (BizComponents), so i get this error

--------------------------------------------------------------------------------

System.ArgumentNullException: Key cannot be null.
Parameter name: key
at System.Collections.Hashtable.get_Item(Object key)
at Microsoft.Practices.WizardFramework.WizardGatheringService.GetWizardConfiguration(XmlElement data)
at Microsoft.Practices.WizardFramework.WizardGatheringService.Microsoft.Practices.Common.Services.IValueGatheringService.Execute(XmlElement data, Boolean allowSuspend)
at Microsoft.Practices.RecipeFramework.VisualStudio.Templates.TemplateGatheringService.Microsoft.Practices.Common.Services.IValueGatheringService.Execute(XmlElement serviceData, Boolean allowSuspend)
at Microsoft.Practices.RecipeFramework.Recipe.Execute(Boolean allowSuspend)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(String recipe, IAssetReference reference, IDictionary arguments)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(String recipe, IDictionary arguments)
at Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate.ExecuteRecipe(Boolean executeActions)
at Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate.RunStarted(Object automationObject, Dictionary`2 replacementsDictionary, WizardRunKind runKind, Object[] customParams)

--------------------------------------------------------------------------------

this is my vstemplate :

<VSTemplate Version="2.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">

<TemplateData>

<Name>Empty Class Business components</Name>

<Description>A class receiving arguments for dynamic code generation</Description>

<Icon Package="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}" ID="4515" />

<ProjectType>CSharp</ProjectType>

<SortOrder>10</SortOrder>

<DefaultName>Class.cs</DefaultName>

</TemplateData>

<TemplateContent>

<References>

<Reference>

<Assembly>System</Assembly>

</Reference>

<Reference>

<Assembly>System.Data</Assembly>

</Reference>

<Reference>

<Assembly>System.Xml</Assembly>

</Reference>

<Reference>

<Assembly>BICoreLib</Assembly>

</Reference>

<Reference>

<Assembly>mscorlib</Assembly>

</Reference>

</References>

<ProjectItem SubType="Code" TargetFileName="$fileinputname$.cs" ReplaceParameters="true">ClassBusinessComponents.cs</ProjectItem>

</TemplateContent>

<WizardExtension>

<Assembly>Microsoft.Practices.RecipeFramework.VisualStudio, Version=1.0.51206.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>

<FullClassName>Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate</FullClassName>

</WizardExtension>

<WizardData>

<Template xmlns="http://schemas.microsoft.com/pag/gax-template"

SchemaVersion="1.0"

Recipe="NewItemClassBusinessComponents">

<References>

</References>

</Template>

</WizardData>

</VSTemplate>

-----------------------------------------------------

and my Recipe

<Recipe Name="NewItemClassBusinessComponents" Recurrent="false">

<xi:include href="TypeAlias.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />

<Caption>Collects information from the user</Caption>

<Description>

This recipe doesn't perform any actions, but showcases the features

available to build highly functional wizards by taking advantage of

type converters and editors.

</Description>

<HostData>

<Icon ID="1429"/>

<CommandBar Name="Project" />

</HostData>

<Arguments>

<!-- Example of automatic UITypeEditor provided by .NET, and a custom value provider -->

<Argument Name="Date" Type="System.DateTime">

<ValueProvider Type="BusinessInteractif.Application.Architecture2005.ValueProviders.DateNowValueProvider, BI.Application.Architecture2005" />

</Argument>

<!-- The following two arguments are not shown to the user, but collaborate to retrieve a value -->

<Argument Name="CurrentProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

<ValueProvider Type="Microsoft.Practices.RecipeFramework.Library.ValueProviders.FirstSelectedProject, Microsoft.Practices.RecipeFramework.Library" />

</Argument>

<Argument Name="TargetNamespace">

<Converter Type="Microsoft.Practices.RecipeFramework.Library.Converters.NamespaceStringConverter, Microsoft.Practices.RecipeFramework.Library"/>

<!-- Shows an argument with a custom type defined in-place, and not collected by the wizard -->

<ValueProvider Type="Evaluator" Expression="$(CurrentProject.Properties.Item('DefaultNamespace').Value).Generated" />

</Argument>

<Argument Name="Project" Type="EnvDTE.Project, EnvDTE" Required="false">

<!-- Converter ensures that a string representation of a project is valid, and also allows conversion to/from it to the Project instance. -->

<Converter Type="Microsoft.Practices.RecipeFramework.Library.Converters.ProjectConverter, Microsoft.Practices.RecipeFramework.Library" />

</Argument>

</Arguments>

</Recipe>



Answer this question

Error "System.ArgumentNullException: Key cannot be null" when i add twice same project item

  • Patrick Strateman

    thanx

    Daniel GAVARIN


  • Newkid

    This is a known issue in the current release. Try adding an empty <GatheringServiceData> elemet on the recipe.


  • Scottah

    This is a known bug in GAX.
    You can solve it by adding an empty <GatheringServiceData> element.

    Let me know if it works ok.


  • Error "System.ArgumentNullException: Key cannot be null" when i add twice same project item