1
Vote

Crash in SplitAndAddItemsFromStringAction.FindOrCreateProjectFolder

description

There is an array out-of-bound exception that will occur in some instances. Can easily be fixed by modifying the function as follows
 
private static ProjectItem FindOrCreateProjectFolder(ProjectItems items, string[] fragments, int index)
    {
        try
        {
            string path = fragments[index];
 
            foreach (ProjectItem item in items)
            {
                if (string.Compare(item.Name, path, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    if (index == fragments.Length - 1)
 
The last line should be modified to
 
                    if (index >= fragments.Length - 1)
 
in order to avoid crashing on ArrayOutOfBoundsException

comments

lothar7 wrote Mar 19, 2009 at 4:18 PM

Here is the stack trace. Seems my first suggestion was wrong. The crash is caused in the first half of the function, but it seems it only happens if one tries to override the default namespace for the entities

Microsoft.Practices.RecipeFramework.ActionExecutionException: An exception occurred during the binding of reference or execution of recipe CreateBEFromDBCS. Error was: Action AddEntities failed to execute:
You can remove the reference to this recipe through the Guidance Package Manager. --->
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Microsoft.Practices.RepositoryFactory.Actions.VisualStudio.SplitAndAddItemsFromStringAction.FindOrCreateProjectFolder(ProjectItems items, String[] fragments, Int32 index)
--- End of inner exception stack trace ---
at Microsoft.Practices.RepositoryFactory.Actions.VisualStudio.SplitAndAddItemsFromStringAction.FindOrCreateProjectFolder(ProjectItems items, String[] fragments, Int32 index)
at Microsoft.Practices.RepositoryFactory.Actions.VisualStudio.SplitAndAddItemsFromStringAction.GetTargetProjectItems(Project project, String relativeTargetPath, String fileName)
at Microsoft.Practices.RepositoryFactory.Actions.VisualStudio.SplitAndAddItemsFromStringAction.Execute()
at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName, Dictionary2 inputValues)
at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName)
at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionCoordinationService.Run(Dictionary
2 declaredActions, XmlElement coordinationData)
at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)
--- End of inner exception stack trace ---
at Microsoft.Practices.RecipeFramework.Recipe.UndoExecutedActionsAndRethrow(Exception ex)
at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)
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(IAssetReference reference)
at Microsoft.Practices.RecipeFramework.RecipeReference.OnExecute()
at Microsoft.Practices.RecipeFramework.AssetReference.Execute()
at Microsoft.Practices.RecipeFramework.VisualStudio.RecipeMenuCommand.OnExec()
at Microsoft.Practices.RecipeFramework.VisualStudio.AssetMenuCommand.Invoke()

wrote Feb 14, 2013 at 2:27 AM