ERROR: Length cannot be less than zero. Parameter name: length


This happens when I open PipelineBuilder (NOT when I hit OK)
I'm not sure why this happened. But exiting and restarting VS seemed to help
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at System.String.Substring(Int32 startIndex, Int32 length)
at VSPipelineBuilder.Connect.Pop(String path) in D:\AppBuilding\PipelineBuilder\VSPipelineBuilder\Connect.cs:line 390
at VSPipelineBuilder.PipelineConfiguration.Pop(String source) in D:\AppBuilding\PipelineBuilder\VSPipelineBuilder\PipelineConfiguration.cs:line 123
at VSPipelineBuilder.PipelineConfiguration.InitializeProject(Project p) in D:\AppBuilding\PipelineBuilder\VSPipelineBuilder\PipelineConfiguration.cs:line 84
at VSPipelineBuilder.PipelineConfiguration.c_projects_SelectedIndexChanged(Object sender, EventArgs e) in D:\AppBuilding\PipelineBuilder\VSPipelineBuilder\PipelineConfiguration.cs:line 26
at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)
at System.Windows.Forms.ComboBox.set_SelectedItem(Object value)
at VSPipelineBuilder.PipelineConfiguration.Initialize(DTE2 root) in D:\AppBuilding\PipelineBuilder\VSPipelineBuilder\PipelineConfiguration.cs:line 75
at VSPipelineBuilder.Connect.Exec(String commandName, vsCommandExecOption executeOption, Object& varIn, Object& varOut, Boolean& handled) in D:\AppBuilding\PipelineBuilder\VSPipelineBuilder\Connect.cs:line 161

file attachments


henke wrote Apr 19, 2009 at 5:22 PM

The reason is probably because Microsoft's programmer wrote a method like this:
    internal static string Pop(string path)
        if (!path.Contains("\\"))
            throw new InvalidOperationException("Path does not contain '\\': " + path);
        return path.Substring(0, path.LastIndexOf('\\'));
I'm not sure whether your bug report is before this code, which I think it is, but look what they replaced it with! Goddag yxskaft!!

I'm in the process of updating the codebase in this plugin to standards which you can live with. (i.e. I'm removing the
try {
// code
// code
// code
// code
} catch (Exception)

and adding checks -- for example, they are assuming the project is named something like "Contract" or "Contracts":
            if (project.Name.Contains("Contracts"))
                contractProject = project;

            else if (contractProject == null && project.Name.Contains("Contract"))
                contractProject = project;
I mean: wtf? (see attached)

This was cool too:
    public Project SourceProject
            if (!String.IsNullOrEmpty(c_projects.SelectedItem.ToString()))
                foreach (Project project in Connect.GetProjectsFromSolution(_root))
                    if (project.Name.Equals(c_projects.SelectedItem.ToString()))
                        return project;
            return null;
It smells like flowers in the spring.

Anyway, I don't think I can commit here, but send me a mail to henrik at h a f dot se, and I'll send you a working version (I'll post it on my site, too, same address).

wrote Apr 19, 2009 at 5:22 PM

wrote Feb 14, 2013 at 8:02 PM